diff options
author | Jay Shrauner <shrauner@google.com> | 2015-01-05 18:39:31 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-01-05 18:39:31 +0000 |
commit | d6e77bd2255ee1b48d3e45ead10a8b2b5d975fc5 (patch) | |
tree | abd45d0e6b0777472e2a73fe95ae8f7a98726159 | |
parent | 8e0e73eb302086ef0eab60226d35dd18e5f1d250 (diff) | |
parent | f924719d491c2b1a1c42234a0a174d975691b483 (diff) | |
download | android_frameworks_ex-d6e77bd2255ee1b48d3e45ead10a8b2b5d975fc5.tar.gz android_frameworks_ex-d6e77bd2255ee1b48d3e45ead10a8b2b5d975fc5.tar.bz2 android_frameworks_ex-d6e77bd2255ee1b48d3e45ead10a8b2b5d975fc5.zip |
am f924719d: am 7158b670: Fix StaleDataExceptions
* commit 'f924719d491c2b1a1c42234a0a174d975691b483':
Fix StaleDataExceptions
-rw-r--r-- | common/java/com/android/common/widget/CompositeCursorAdapter.java | 11 |
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; |