summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2013-07-07 12:57:09 +0200
committerDanny Baumann <dannybaumann@web.de>2013-07-07 13:05:33 +0200
commit17006897b1aad1632c735505d9432e682fcef98b (patch)
treeb2f48a2eb8fa5018294373017d4a10314334248f /core/java
parentffda8dd5c1f569d711b47af8cfad034fb1ba02cc (diff)
downloadframeworks_base-17006897b1aad1632c735505d9432e682fcef98b.zip
frameworks_base-17006897b1aad1632c735505d9432e682fcef98b.tar.gz
frameworks_base-17006897b1aad1632c735505d9432e682fcef98b.tar.bz2
Fix requery behaviour of MemoryCursor.
As we can't restore the contents of the cursor window, we need to keep it on deactivation so we can restore it on requery(). Change-Id: I06f688bbe9120c307bdc3ddbc3833416becdec82
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/database/MemoryCursor.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/core/java/android/database/MemoryCursor.java b/core/java/android/database/MemoryCursor.java
index 7eb71db..e222819 100644
--- a/core/java/android/database/MemoryCursor.java
+++ b/core/java/android/database/MemoryCursor.java
@@ -26,7 +26,7 @@ import android.database.DatabaseUtils;
* @hide
*/
public class MemoryCursor extends AbstractWindowedCursor {
-
+ private CursorWindow mDeactivatedWindow;
private final String[] mColumnNames;
public MemoryCursor(String name, String[] columnNames) {
@@ -47,4 +47,28 @@ public class MemoryCursor extends AbstractWindowedCursor {
public String[] getColumnNames() {
return mColumnNames;
}
+
+ @Override
+ public boolean requery() {
+ if (mDeactivatedWindow != null) {
+ setWindow(mDeactivatedWindow);
+ mDeactivatedWindow = null;
+ }
+ return super.requery();
+ }
+
+ @Override
+ protected void onDeactivateOrClose() {
+ // when deactivating the cursor, we need to keep our in-memory cursor
+ // window as we have no chance of requerying it later on
+ if (!isClosed() && getWindow() != null) {
+ mDeactivatedWindow = getWindow();
+ mWindow = null;
+ }
+ super.onDeactivateOrClose();
+ if (isClosed() && mDeactivatedWindow != null) {
+ mDeactivatedWindow.close();
+ mDeactivatedWindow = null;
+ }
+ }
}