OSDN Git Service

am 5edd0cbd: Fix build.
[android-x86/packages-apps-Music.git] / src / com / android / music / ArtistAlbumBrowserActivity.java
index cc793df..1ab0ee9 100644 (file)
@@ -164,11 +164,12 @@ public class ArtistAlbumBrowserActivity extends ExpandableListActivity
         mLastListPosFine = lv.getChildAt(0).getTop();
         
         MusicUtils.unbindFromService(this);
-        if (!mAdapterSent) {
-            Cursor c = mAdapter.getCursor();
-            if (c != null) {
-                c.close();
-            }
+        // If we have an adapter and didn't send it off to another activity yet, we should
+        // close its cursor, which we do by assigning a null cursor to it. Doing this
+        // instead of closing the cursor directly keeps the framework from accessing
+        // the closed cursor later.
+        if (!mAdapterSent && mAdapter != null) {
+            mAdapter.changeCursor(null);
         }
         // Because we pass the adapter to the next activity, we need to make
         // sure it doesn't keep a reference to this activity. We can do this
@@ -817,6 +818,10 @@ public class ArtistAlbumBrowserActivity extends ExpandableListActivity
 
         @Override
         public void changeCursor(Cursor cursor) {
+            if (mActivity.isFinishing() && cursor != null) {
+                cursor.close();
+                cursor = null;
+            }
             if (cursor != mActivity.mArtistCursor) {
                 mActivity.mArtistCursor = cursor;
                 getColumnIndices(cursor);