Added Type Arguments to Samples, to reduce Warnings and get a litle bit more Compiler Code checking for "new" Android Programmers
Change-Id: I25add019e99fec88c8422da14f3e18246ca0f0b5
This commit is contained in:
@@ -52,8 +52,8 @@ public class ApiDemos extends ListActivity {
|
|||||||
getListView().setTextFilterEnabled(true);
|
getListView().setTextFilterEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List getData(String prefix) {
|
protected List<Map<String, Object>> getData(String prefix) {
|
||||||
List<Map> myData = new ArrayList<Map>();
|
List<Map<String, Object>> myData = new ArrayList<Map<String, Object>>();
|
||||||
|
|
||||||
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
|
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||||
mainIntent.addCategory(Intent.CATEGORY_SAMPLE_CODE);
|
mainIntent.addCategory(Intent.CATEGORY_SAMPLE_CODE);
|
||||||
@@ -107,10 +107,11 @@ public class ApiDemos extends ListActivity {
|
|||||||
return myData;
|
return myData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Comparator<Map> sDisplayNameComparator = new Comparator<Map>() {
|
private final static Comparator<Map<String, Object>> sDisplayNameComparator =
|
||||||
|
new Comparator<Map<String, Object>>() {
|
||||||
private final Collator collator = Collator.getInstance();
|
private final Collator collator = Collator.getInstance();
|
||||||
|
|
||||||
public int compare(Map map1, Map map2) {
|
public int compare(Map<String, Object> map1, Map<String, Object> map2) {
|
||||||
return collator.compare(map1.get("title"), map2.get("title"));
|
return collator.compare(map1.get("title"), map2.get("title"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -128,7 +129,7 @@ public class ApiDemos extends ListActivity {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addItem(List<Map> data, String name, Intent intent) {
|
protected void addItem(List<Map<String, Object>> data, String name, Intent intent) {
|
||||||
Map<String, Object> temp = new HashMap<String, Object>();
|
Map<String, Object> temp = new HashMap<String, Object>();
|
||||||
temp.put("title", name);
|
temp.put("title", name);
|
||||||
temp.put("intent", intent);
|
temp.put("intent", intent);
|
||||||
@@ -136,11 +137,11 @@ public class ApiDemos extends ListActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
Map map = (Map) l.getItemAtPosition(position);
|
Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position);
|
||||||
|
|
||||||
Intent intent = (Intent) map.get("intent");
|
Intent intent = (Intent) map.get("intent");
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user