OSDN Git Service

Make sure we actually have an adapter before trying to access it.
authorMarco Nelissen <marcone@google.com>
Mon, 12 Oct 2009 19:29:09 +0000 (12:29 -0700)
committerMarco Nelissen <marcone@google.com>
Mon, 12 Oct 2009 19:29:09 +0000 (12:29 -0700)
Fixes bug 2177763.

src/com/android/music/AlbumBrowserActivity.java
src/com/android/music/ArtistAlbumBrowserActivity.java
src/com/android/music/PlaylistBrowserActivity.java
src/com/android/music/TrackBrowserActivity.java

index 49a3893..49d511c 100644 (file)
@@ -147,7 +147,9 @@ public class AlbumBrowserActivity extends ListActivity
     @Override
     public void onDestroy() {
         MusicUtils.unbindFromService(this);
-        if (!mAdapterSent) {
+        // if we have an adapter and didn't send it off to another activity yet, we should
+        // close the cursor
+        if (!mAdapterSent && mAdapter != null) {
             Cursor c = mAdapter.getCursor();
             if (c != null) {
                 c.close();
index 9aa42b4..8fb452b 100644 (file)
@@ -154,7 +154,9 @@ public class ArtistAlbumBrowserActivity extends ExpandableListActivity
     @Override
     public void onDestroy() {
         MusicUtils.unbindFromService(this);
-        if (!mAdapterSent) {
+        // if we have an adapter and didn't send it off to another activity yet, we should
+        // close the cursor
+        if (!mAdapterSent && mAdapter != null) {
             Cursor c = mAdapter.getCursor();
             if (c != null) {
                 c.close();
index ccdb529..3c5ad22 100644 (file)
@@ -169,7 +169,9 @@ public class PlaylistBrowserActivity extends ListActivity
     @Override
     public void onDestroy() {
         MusicUtils.unbindFromService(this);
-        if (!mAdapterSent) {
+        // if we have an adapter and didn't send it off to another activity yet, we should
+        // close the cursor
+        if (!mAdapterSent && mAdapter != null) {
             Cursor c = mAdapter.getCursor();
             if (c != null) {
                 c.close();
index 078b17c..f44c61b 100644 (file)
@@ -233,9 +233,9 @@ public class TrackBrowserActivity extends ListActivity
             // we end up here in case we never registered the listeners
         }
         
-        // if we didn't send the adapter off to another activity, we should
+        // if we have an adapter and didn't send it off to another activity yet, we should
         // close the cursor
-        if (!mAdapterSent) {
+        if (!mAdapterSent && mAdapter != null) {
             Cursor c = mAdapter.getCursor();
             if (c != null) {
                 c.close();