summaryrefslogtreecommitdiffstats
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeMapActivity.java30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
index def8537..c352b58 100644
--- a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
+++ b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
@@ -22,8 +22,12 @@ public final class UnicodeMapActivity extends ListActivity {
protected final List<UnicodeDisplayable> rootList
= new ArrayList<UnicodeDisplayable>(200);
- protected final List<List<UnicodeDisplayable>> stack
- = new ArrayList<List<UnicodeDisplayable>>(10);
+ protected final List<UnicodeArrayAdapter> stack
+ = new ArrayList<UnicodeArrayAdapter>(10);
+ protected final List<Integer> positionStack
+ = new ArrayList<Integer>(10);
+ protected final List<Integer> positionYStack
+ = new ArrayList<Integer>(10);
protected void launchPopulation() {
final ProgressDialog progress = new ProgressDialog(this);
@@ -64,8 +68,10 @@ public final class UnicodeMapActivity extends ListActivity {
launchPopulation();
for ( UnicodeCharacter.Range rng : UnicodeCharacter.Range.values() )
rootList.add(rng);
- stack.add(rootList);
- setListAdapter(new UnicodeArrayAdapter(this, rootList));
+ UnicodeArrayAdapter rootAdapter
+ = new UnicodeArrayAdapter(this, rootList);
+ stack.add(rootAdapter);
+ setListAdapter(rootAdapter);
final ClipboardManager cmgr
= (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
final Button btn = (Button) findViewById(R.id.button);
@@ -94,8 +100,13 @@ public final class UnicodeMapActivity extends ListActivity {
= new ArrayList<UnicodeDisplayable>(db.countRange(from,to));
for ( UnicodeCharacter ch : db.getRange(from,to) )
list.add(ch);
- stack.add(list);
- setListAdapter(new UnicodeArrayAdapter(UnicodeMapActivity.this, list));
+ UnicodeArrayAdapter adapter
+ = new UnicodeArrayAdapter(UnicodeMapActivity.this,
+ list);
+ stack.add(adapter);
+ positionStack.add(position);
+ positionYStack.add(view.getTop());
+ setListAdapter(adapter);
} else
throw new AssertionError("unknown UnicodeDisplayable");
}
@@ -105,10 +116,11 @@ public final class UnicodeMapActivity extends ListActivity {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ( ( keyCode == KeyEvent.KEYCODE_BACK) && stack.size() > 1 ) {
+ final ListView lv = getListView();
stack.remove(stack.size()-1);
- List<UnicodeDisplayable> list
- = stack.get(stack.size()-1);
- setListAdapter(new UnicodeArrayAdapter(UnicodeMapActivity.this, list));
+ setListAdapter(stack.get(stack.size()-1));
+ lv.setSelectionFromTop(positionStack.remove(positionStack.size()-1),
+ positionYStack.remove(positionYStack.size()-1));
return true;
}
return super.onKeyDown(keyCode, event);