1 /* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.view.animation.cts; 18 19 import android.view.cts.R; 20 21 import android.app.Activity; 22 import android.database.DataSetObserver; 23 import android.os.Bundle; 24 import android.view.View; 25 import android.view.ViewGroup; 26 import android.widget.AbsListView; 27 import android.widget.GridView; 28 import android.widget.ImageView; 29 import android.widget.ListAdapter; 30 31 public class GridLayoutAnimCtsActivity extends Activity { 32 33 private GridView mGridView; 34 private static final int GRID_NUM = 9; 35 36 @Override onCreate(Bundle savedInstanceState)37 protected void onCreate(Bundle savedInstanceState) { 38 super.onCreate(savedInstanceState); 39 setContentView(R.layout.gridlayout_anim_controller_layout); 40 mGridView = (GridView) findViewById(R.id.gridlayout_anim_gridview); 41 mGridView.setAdapter(new MockGridViewAdapter(GRID_NUM)); 42 } 43 getGridView()44 public GridView getGridView() { 45 return mGridView; 46 } 47 48 private class MockGridViewAdapter implements ListAdapter { 49 private final int mCount; 50 MockGridViewAdapter(int count)51 MockGridViewAdapter(int count) { 52 mCount = count; 53 } 54 MockGridViewAdapter()55 MockGridViewAdapter() { 56 this(1); 57 } 58 areAllItemsEnabled()59 public boolean areAllItemsEnabled() { 60 return true; 61 } 62 isEnabled(int position)63 public boolean isEnabled(int position) { 64 return true; 65 } 66 registerDataSetObserver(DataSetObserver observer)67 public void registerDataSetObserver(DataSetObserver observer) { 68 } 69 unregisterDataSetObserver(DataSetObserver observer)70 public void unregisterDataSetObserver(DataSetObserver observer) { 71 } 72 getCount()73 public int getCount() { 74 return mCount; 75 } 76 getItem(int position)77 public Object getItem(int position) { 78 return position; 79 } 80 getItemId(int position)81 public long getItemId(int position) { 82 return position; 83 } 84 hasStableIds()85 public boolean hasStableIds() { 86 return false; 87 } 88 getView(int position, View convertView, ViewGroup parent)89 public View getView(int position, View convertView, ViewGroup parent) { 90 if ((convertView != null) && (convertView instanceof ImageView)) { 91 ((ImageView) convertView).setImageResource(R.drawable.size_48x48); 92 return convertView; 93 } 94 95 ImageView newView = new ImageView(GridLayoutAnimCtsActivity.this); 96 AbsListView.LayoutParams params = new AbsListView.LayoutParams( 97 AbsListView.LayoutParams.WRAP_CONTENT, AbsListView.LayoutParams.WRAP_CONTENT); 98 newView.setLayoutParams(params); 99 newView.setImageResource(R.drawable.size_48x48); 100 return newView; 101 } 102 getItemViewType(int position)103 public int getItemViewType(int position) { 104 return 0; 105 } 106 getViewTypeCount()107 public int getViewTypeCount() { 108 return 1; 109 } 110 isEmpty()111 public boolean isEmpty() { 112 return false; 113 } 114 } 115 } 116