Revision f209a803
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/examples/TableOfContents.java | ||
---|---|---|
137 | 137 |
|
138 | 138 |
@Override |
139 | 139 |
public void onCreate(Bundle savedInstanceState) |
140 |
{ |
|
141 |
super.onCreate(savedInstanceState); |
|
142 |
setContentView(R.layout.table_of_contents); |
|
140 |
{
|
|
141 |
super.onCreate(savedInstanceState);
|
|
142 |
setContentView(R.layout.table_of_contents);
|
|
143 | 143 |
|
144 |
final List<Map<String, Object>> data = new ArrayList<>(); |
|
145 |
final SparseArray<Class<? extends Activity>> activityMapping = new SparseArray<>(); |
|
144 |
final List<Map<String, Object>> data = new ArrayList<>();
|
|
145 |
final SparseArray<Class<? extends Activity>> activityMapping = new SparseArray<>();
|
|
146 | 146 |
|
147 |
int index=0; |
|
147 |
int index=0;
|
|
148 | 148 |
|
149 |
for( Application app : Application.values() ) |
|
150 |
{ |
|
151 |
final Map<String, Object> item = new HashMap<>(); |
|
152 |
item.put(ITEM_IMAGE, app.icon); |
|
153 |
item.put(ITEM_TITLE, (index+1)+". "+getText(app.title)); |
|
154 |
item.put(ITEM_SUBTITLE, getText(app.subtitle)); |
|
155 |
data.add(item); |
|
156 |
activityMapping.put(index++, app.activity); |
|
157 |
} |
|
149 |
for( Application app : Application.values() )
|
|
150 |
{
|
|
151 |
final Map<String, Object> item = new HashMap<>();
|
|
152 |
item.put(ITEM_IMAGE, app.icon);
|
|
153 |
item.put(ITEM_TITLE, (index+1)+". "+getText(app.title));
|
|
154 |
item.put(ITEM_SUBTITLE, getText(app.subtitle));
|
|
155 |
data.add(item);
|
|
156 |
activityMapping.put(index++, app.activity);
|
|
157 |
}
|
|
158 | 158 |
|
159 |
final SimpleAdapter dataAdapter = new SimpleAdapter( this, |
|
160 |
data, |
|
161 |
R.layout.toc_item, |
|
162 |
new String[] {ITEM_IMAGE, ITEM_TITLE, ITEM_SUBTITLE}, |
|
163 |
new int[] {R.id.Image, R.id.Title, R.id.SubTitle} ); |
|
164 |
setListAdapter(dataAdapter);
|
|
159 |
final SimpleAdapter dataAdapter = new SimpleAdapter( this,
|
|
160 |
data,
|
|
161 |
R.layout.toc_item,
|
|
162 |
new String[] {ITEM_IMAGE, ITEM_TITLE, ITEM_SUBTITLE},
|
|
163 |
new int[] {R.id.Image, R.id.Title, R.id.SubTitle} );
|
|
164 |
setListAdapter(dataAdapter);
|
|
165 | 165 |
|
166 |
getListView().setOnItemClickListener(new OnItemClickListener() |
|
167 |
{ |
|
168 |
@Override |
|
169 |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) |
|
166 |
getListView().setOnItemClickListener(new OnItemClickListener() |
|
170 | 167 |
{ |
171 |
final Class<? extends Activity> activityToLaunch = activityMapping.get(position); |
|
172 |
|
|
173 |
if (activityToLaunch != null) |
|
168 |
@Override |
|
169 |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) |
|
174 | 170 |
{ |
175 |
final Intent launchIntent = new Intent(TableOfContents.this, activityToLaunch); |
|
176 |
startActivity(launchIntent); |
|
177 |
} |
|
178 |
} |
|
179 |
}); |
|
180 |
} |
|
171 |
final Class<? extends Activity> activityToLaunch = activityMapping.get(position); |
|
172 |
|
|
173 |
if (activityToLaunch != null) |
|
174 |
{ |
|
175 |
final Intent launchIntent = new Intent(TableOfContents.this, activityToLaunch); |
|
176 |
startActivity(launchIntent); |
|
177 |
} |
|
178 |
} |
|
179 |
}); |
|
180 |
} |
|
181 | 181 |
} |
182 |
|
|
183 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Convert Sink to not use the depreciated MeshBase.setStretch() API.