Methods Summary |
---|
protected void | addItem(java.util.List data, java.lang.String name, java.lang.String path)
HashMap temp = new HashMap();
temp.put("title", name);
temp.put("path", path);
data.add(temp);
|
abstract boolean | fileFilter(java.io.File f)
|
protected java.util.List | getData()
List myData = new ArrayList<HashMap>();
File f = new File(mPath);
if (!f.exists()) {
addItem(myData, "!LayoutTests path missing!", "");
return myData;
}
String[] files = f.list();
Arrays.sort(files);
for (int i = 0; i < files.length; i++) {
StringBuilder sb = new StringBuilder(mPath);
sb.append(File.separatorChar);
sb.append(files[i]);
String path = sb.toString();
File c = new File(path);
if (fileFilter(c)) {
if (c.isDirectory()) {
addItem(myData, "<"+files[i]+">", path);
if (mFocusFile != null && mFocusFile.equals(files[i]))
mFocusIndex = myData.size()-1;
}
else
addItem(myData, files[i], path);
}
}
return myData;
|
public void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
setupPath();
updateList();
|
public boolean | onKeyDown(int keyCode, android.view.KeyEvent event)
switch (keyCode)
{
case KeyEvent.KEYCODE_DPAD_LEFT:
if (mPath.length() > mBaseLength) {
File f = new File(mPath);
mFocusFile = f.getName();
mFocusIndex = 0;
f = f.getParentFile();
mPath = f.getPath();
updateList();
return true;
}
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
{
Map map = (Map) getListView().getItemAtPosition(getListView().getSelectedItemPosition());
String path = (String)map.get("path");
if ((new File(path)).isDirectory()) {
mPath = path;
mFocusFile = null;
updateList();
} else {
processFile(path, false);
}
return true;
}
default:
break;
}
return super.onKeyDown(keyCode, event);
|
protected void | onListItemClick(android.widget.ListView l, android.view.View v, int position, long id)
Map map = (Map) l.getItemAtPosition(position);
String path = (String)map.get("path");
if ((new File(path)).isDirectory()) {
mPath = path;
mFocusFile = null;
updateList();
} else {
processFile(path, false);
}
|
abstract void | processFile(java.lang.String filename, boolean selection)
|
protected void | setupPath()
mPath = "/sdcard/android/layout_tests";
mBaseLength = mPath.length();
|
protected void | updateList()
setListAdapter(new SimpleAdapter(this,
getData(),
android.R.layout.simple_list_item_1,
new String[] {"title"},
new int[] {android.R.id.text1}));
String title = mPath; //.substring(mBaseLength-11); // show the word LayoutTests
setTitle(title);
getListView().setSelection(mFocusIndex);
|