aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-05-28 20:28:52 +0900
committerJean Chalard <jchalard@google.com>2013-05-29 11:52:04 +0900
commit2b34b4eab6b04299205f47a92311d4d00f9d805f (patch)
tree61a4d90138c074f5cb082a37eb12fd66e8fb5efb /java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java
parent305509ed2feffa5c57cd21bb7cc137e444df3390 (diff)
downloadlatinime-2b34b4eab6b04299205f47a92311d4d00f9d805f.tar.gz
latinime-2b34b4eab6b04299205f47a92311d4d00f9d805f.tar.xz
latinime-2b34b4eab6b04299205f47a92311d4d00f9d805f.zip
Rub some butter on dictionary list scrolling.
The default implementation for preferences refuses to cache the views for custom preferences at all. We can do it, but the system won't do it for us, so this does it. This makes the screen scrolling smooth again. Incidentally it also fixes the bug where the button may not animate on the first element. Bug: 8882722 Bug: 8883108 Change-Id: I9b2306ac4bf93761a808ebfee3477a65f017cddf
Diffstat (limited to 'java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java')
-rw-r--r--java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java b/java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java
index de3711c27..5ad5900d4 100644
--- a/java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java
+++ b/java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java
@@ -16,8 +16,11 @@
package com.android.inputmethod.dictionarypack;
+import android.view.View;
+
import com.android.inputmethod.latin.CollectionUtils;
+import java.util.ArrayList;
import java.util.HashMap;
/**
@@ -37,6 +40,7 @@ public class DictionaryListInterfaceState {
}
private HashMap<String, State> mWordlistToState = CollectionUtils.newHashMap();
+ private ArrayList<View> mViewCache = CollectionUtils.newArrayList();
public boolean isOpen(final String wordlistId) {
final State state = mWordlistToState.get(wordlistId);
@@ -64,4 +68,16 @@ public class DictionaryListInterfaceState {
state.mOpen = false;
}
}
+
+ public View findFirstOrphanedView() {
+ for (final View v : mViewCache) {
+ if (null == v.getParent()) return v;
+ }
+ return null;
+ }
+
+ public View addToCacheAndReturnView(final View view) {
+ mViewCache.add(view);
+ return view;
+ }
}