diff options
author | Danny Baumann <dannybaumann@web.de> | 2013-07-09 23:24:06 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2013-07-09 23:24:06 -0700 |
commit | 34b32f417964496d14d043368eac521159247ea7 (patch) | |
tree | bee879fcff24d7023bf9721918af4c829066d468 /core/java | |
parent | 33c5bc476e4a3d612d09efc5d3f8643c042dadb4 (diff) | |
parent | 17006897b1aad1632c735505d9432e682fcef98b (diff) | |
download | frameworks_base-34b32f417964496d14d043368eac521159247ea7.zip frameworks_base-34b32f417964496d14d043368eac521159247ea7.tar.gz frameworks_base-34b32f417964496d14d043368eac521159247ea7.tar.bz2 |
Merge "Fix requery behaviour of MemoryCursor." into cm-10.1
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/database/MemoryCursor.java | 26 |
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; + } + } } |