VectorDrawableTestpublic class VectorDrawableTest extends android.app.ListActivity
Fields Summary |
---|
private static final String | EXTRA_PATH | private static final String | CATEGORY_HWUI_TEST | private static final Comparator | sDisplayNameComparator |
Methods Summary |
---|
protected android.content.Intent | activityIntent(java.lang.String pkg, java.lang.String componentName)
Intent result = new Intent();
result.setClassName(pkg, componentName);
return result;
| protected void | addItem(java.util.List data, java.lang.String name, android.content.Intent intent)
Map<String, Object> temp = new HashMap<String, Object>();
temp.put("title", name);
temp.put("intent", intent);
data.add(temp);
| protected android.content.Intent | browseIntent(java.lang.String path)
Intent result = new Intent();
result.setClass(this, VectorDrawableTest.class);
result.putExtra(EXTRA_PATH, path);
return result;
| protected java.util.List | getData(java.lang.String prefix)
List<Map<String, Object>> myData = new ArrayList<Map<String, Object>>();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(CATEGORY_HWUI_TEST);
PackageManager pm = getPackageManager();
List<ResolveInfo> list = pm.queryIntentActivities(mainIntent, 0);
if (null == list)
return myData;
String[] prefixPath;
String prefixWithSlash = prefix;
if (prefix.equals("")) {
prefixPath = null;
} else {
prefixPath = prefix.split("/");
prefixWithSlash = prefix + "/";
}
int len = list.size();
Map<String, Boolean> entries = new HashMap<String, Boolean>();
for (int i = 0; i < len; i++) {
ResolveInfo info = list.get(i);
CharSequence labelSeq = info.loadLabel(pm);
String label = labelSeq != null
? labelSeq.toString()
: info.activityInfo.name;
if (prefixWithSlash.length() == 0 || label.startsWith(prefixWithSlash)) {
String[] labelPath = label.split("/");
String nextLabel = prefixPath == null ? labelPath[0] : labelPath[prefixPath.length];
if ((prefixPath != null ? prefixPath.length : 0) == labelPath.length - 1) {
addItem(myData, nextLabel, activityIntent(
info.activityInfo.applicationInfo.packageName,
info.activityInfo.name));
} else {
if (entries.get(nextLabel) == null) {
addItem(myData, nextLabel, browseIntent(prefix.equals("") ?
nextLabel : prefix + "/" + nextLabel));
entries.put(nextLabel, true);
}
}
}
}
Collections.sort(myData, sDisplayNameComparator);
return myData;
| public void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String path = intent.getStringExtra("com.android.test.hwui.Path");
if (path == null) {
path = "";
}
setListAdapter(new SimpleAdapter(this, getData(path),
android.R.layout.simple_list_item_1, new String[] { "title" },
new int[] { android.R.id.text1 }));
getListView().setTextFilterEnabled(true);
| protected void | onListItemClick(android.widget.ListView l, android.view.View v, int position, long id)
Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position);
Intent intent = (Intent) map.get("intent");
startActivity(intent);
|
|