diff options
| author | Jin Cao <jinyan@google.com> | 2014-09-08 10:46:41 -0700 |
|---|---|---|
| committer | Jin Cao <jinyan@google.com> | 2014-09-08 10:46:41 -0700 |
| commit | 31c33ef87cb0612250b812233ffbc0c46e88a371 (patch) | |
| tree | aafbb46f149273acf2417be66498ea53fbceb5a6 | |
| parent | 0cfdd9826106f2ae640301c85e5c9628e711aadf (diff) | |
| download | android_frameworks_opt_chips-31c33ef87cb0612250b812233ffbc0c46e88a371.tar.gz android_frameworks_opt_chips-31c33ef87cb0612250b812233ffbc0c46e88a371.tar.bz2 android_frameworks_opt_chips-31c33ef87cb0612250b812233ffbc0c46e88a371.zip | |
Only cache current selection if there are pending searches
If the current result is empty, only cache the current list
if there are pending searches (e.g. directory). Don't cache
it if there are no alternate searches.
b/17376740
Change-Id: I8a54b845ebc76dbbe651835b31446f05fd210565
| -rw-r--r-- | src/com/android/ex/chips/BaseRecipientAdapter.java | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/com/android/ex/chips/BaseRecipientAdapter.java b/src/com/android/ex/chips/BaseRecipientAdapter.java index 24f7a3e..b3474bb 100644 --- a/src/com/android/ex/chips/BaseRecipientAdapter.java +++ b/src/com/android/ex/chips/BaseRecipientAdapter.java @@ -281,12 +281,9 @@ public class BaseRecipientAdapter extends BaseAdapter implements Filterable, Acc mNonAggregatedEntries = defaultFilterResult.nonAggregatedEntries; mExistingDestinations = defaultFilterResult.existingDestinations; - // If there are no local results, in the new result set, cache off what had been - // shown to the user for use until the first directory result is returned - if (defaultFilterResult.entries.size() == 0 && - defaultFilterResult.paramsList != null) { - cacheCurrentEntries(); - } + cacheCurrentEntriesIfNeeded(defaultFilterResult.entries.size(), + defaultFilterResult.paramsList == null ? 0 : + defaultFilterResult.paramsList.size()); updateEntries(defaultFilterResult.entries); @@ -818,6 +815,19 @@ public class BaseRecipientAdapter extends BaseAdapter implements Filterable, Acc notifyDataSetChanged(); } + /** + * If there are no local results and we are searching alternate results, + * in the new result set, cache off what had been shown to the user for use until + * the first directory result is returned + * @param newEntryCount number of newly loaded entries + * @param paramListCount number of alternate filters it will search (including the current one). + */ + protected void cacheCurrentEntriesIfNeeded(int newEntryCount, int paramListCount) { + if (newEntryCount == 0 && paramListCount > 1) { + cacheCurrentEntries(); + } + } + protected void cacheCurrentEntries() { mTempEntries = mEntries; } |
