From a3396e09400fc065aa773e076de7a44323e3ce6b Mon Sep 17 00:00:00 2001 From: Christian Mehlmauer Date: Thu, 20 May 2010 20:11:29 +0200 Subject: [PATCH] Added Type Arguments to Samples, to reduce Warnings and get a litle bit more Compiler Code checking for "new" Android Programmers Change-Id: I25add019e99fec88c8422da14f3e18246ca0f0b5 --- .../src/com/example/android/apis/ApiDemos.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/samples/ApiDemos/src/com/example/android/apis/ApiDemos.java b/samples/ApiDemos/src/com/example/android/apis/ApiDemos.java index 78b1fd752..39f24b699 100644 --- a/samples/ApiDemos/src/com/example/android/apis/ApiDemos.java +++ b/samples/ApiDemos/src/com/example/android/apis/ApiDemos.java @@ -52,8 +52,8 @@ public class ApiDemos extends ListActivity { getListView().setTextFilterEnabled(true); } - protected List getData(String prefix) { - List myData = new ArrayList(); + protected List> getData(String prefix) { + List> myData = new ArrayList>(); Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_SAMPLE_CODE); @@ -107,10 +107,11 @@ public class ApiDemos extends ListActivity { return myData; } - private final static Comparator sDisplayNameComparator = new Comparator() { + private final static Comparator> sDisplayNameComparator = + new Comparator>() { private final Collator collator = Collator.getInstance(); - public int compare(Map map1, Map map2) { + public int compare(Map map1, Map map2) { return collator.compare(map1.get("title"), map2.get("title")); } }; @@ -128,7 +129,7 @@ public class ApiDemos extends ListActivity { return result; } - protected void addItem(List data, String name, Intent intent) { + protected void addItem(List> data, String name, Intent intent) { Map temp = new HashMap(); temp.put("title", name); temp.put("intent", intent); @@ -136,11 +137,11 @@ public class ApiDemos extends ListActivity { } @Override + @SuppressWarnings("unchecked") protected void onListItemClick(ListView l, View v, int position, long id) { - Map map = (Map) l.getItemAtPosition(position); + Map map = (Map)l.getItemAtPosition(position); Intent intent = (Intent) map.get("intent"); startActivity(intent); } - }