summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Shrauner <shrauner@google.com>2015-01-05 18:33:56 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-01-05 18:33:56 +0000
commitf924719d491c2b1a1c42234a0a174d975691b483 (patch)
tree7385b280fecf898658d25b35f191bd35209ad7c4
parentb39a8a0b13bd48abb77439f62454c2f737b95f45 (diff)
parent7158b6705d330ac1e61d5aa51c51b54507c4ab88 (diff)
downloadandroid_frameworks_ex-f924719d491c2b1a1c42234a0a174d975691b483.zip
android_frameworks_ex-f924719d491c2b1a1c42234a0a174d975691b483.tar.gz
android_frameworks_ex-f924719d491c2b1a1c42234a0a174d975691b483.tar.bz2
am 7158b670: Fix StaleDataExceptions
* commit '7158b6705d330ac1e61d5aa51c51b54507c4ab88': Fix StaleDataExceptions
-rw-r--r--common/java/com/android/common/widget/CompositeCursorAdapter.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/common/java/com/android/common/widget/CompositeCursorAdapter.java b/common/java/com/android/common/widget/CompositeCursorAdapter.java
index dddbcf6..8a3fa9b 100644
--- a/common/java/com/android/common/widget/CompositeCursorAdapter.java
+++ b/common/java/com/android/common/widget/CompositeCursorAdapter.java
@@ -170,7 +170,12 @@ public abstract class CompositeCursorAdapter extends BaseAdapter {
mCount = 0;
for (Partition partition : mPartitions) {
Cursor cursor = partition.cursor;
- int count = cursor != null ? cursor.getCount() : 0;
+ int count;
+ if (cursor == null || cursor.isClosed()) {
+ count = 0;
+ } else {
+ count = cursor.getCount();
+ }
if (partition.hasHeader) {
if (count != 0 || partition.showIfEmpty) {
count++;
@@ -428,7 +433,9 @@ public abstract class CompositeCursorAdapter extends BaseAdapter {
return null;
}
Cursor cursor = mPartition.cursor;
- cursor.moveToPosition(offset);
+ if (cursor == null || cursor.isClosed() || !cursor.moveToPosition(offset)) {
+ return null;
+ }
return cursor;
}
start = end;