OSDN Git Service

Fix scroll position of album songs list.
authorMarco Nelissen <marcone@google.com>
Mon, 14 Dec 2009 23:59:30 +0000 (15:59 -0800)
committerMarco Nelissen <marcone@google.com>
Mon, 14 Dec 2009 23:59:30 +0000 (15:59 -0800)
src/com/android/music/MusicUtils.java
src/com/android/music/TrackBrowserActivity.java

index a67db7d..58f9bee 100644 (file)
@@ -1054,7 +1054,7 @@ public class MusicUtils {
     
     static int sActiveTabIndex = -1;
     
-    static void updateButtonBar(Activity a, int highlight) {
+    static boolean updateButtonBar(Activity a, int highlight) {
         final TabWidget ll = (TabWidget) a.findViewById(R.id.buttonbar);
         boolean withtabs = false;
         Intent intent = a.getIntent();
@@ -1064,7 +1064,7 @@ public class MusicUtils {
         
         if (highlight == 0 || !withtabs) {
             ll.setVisibility(View.GONE);
-            return;
+            return withtabs;
         } else if (withtabs) {
             ll.setVisibility(View.VISIBLE);
         }
@@ -1097,6 +1097,7 @@ public class MusicUtils {
                     processTabClick((Activity)ll.getContext(), v, ll.getChildAt(sActiveTabIndex).getId());
                 }});
         }
+        return withtabs;
     }
 
     static void processTabClick(Activity a, View v, int current) {
index 8f33958..b544c4f 100644 (file)
@@ -96,6 +96,7 @@ public class TrackBrowserActivity extends ListActivity
     private long mSelectedId;
     private static int mLastListPosCourse = -1;
     private static int mLastListPosFine = -1;
+    private boolean mUseLastListPos = false;
 
     public TrackBrowserActivity()
     {
@@ -156,7 +157,7 @@ public class TrackBrowserActivity extends ListActivity
         };
 
         setContentView(R.layout.media_picker_activity);
-        MusicUtils.updateButtonBar(this, R.id.songtab);
+        mUseLastListPos = MusicUtils.updateButtonBar(this, R.id.songtab);
         mTrackList = getListView();
         mTrackList.setOnCreateContextMenuListener(this);
         if (mEditMode) {
@@ -234,7 +235,7 @@ public class TrackBrowserActivity extends ListActivity
     @Override
     public void onDestroy() {
         ListView lv = getListView();
-        if (lv != null) {
+        if (lv != null && mUseLastListPos) {
             mLastListPosCourse = lv.getFirstVisiblePosition();
             View cv = lv.getChildAt(0);
             if (cv != null) {
@@ -352,8 +353,12 @@ public class TrackBrowserActivity extends ListActivity
             return;
         }
 
+        MusicUtils.hideDatabaseError(this);
+        mUseLastListPos = MusicUtils.updateButtonBar(this, R.id.songtab);
+        setTitle();
+
         // Restore previous position
-        if (mLastListPosCourse >= 0) {
+        if (mLastListPosCourse >= 0 && mUseLastListPos) {
             ListView lv = getListView();
             // this hack is needed because otherwise the position doesn't change
             // for the 2nd (non-limited) cursor
@@ -364,10 +369,6 @@ public class TrackBrowserActivity extends ListActivity
             }
         }
 
-        MusicUtils.hideDatabaseError(this);
-        MusicUtils.updateButtonBar(this, R.id.songtab);
-        setTitle();
-
         // When showing the queue, position the selection on the currently playing track
         // Otherwise, position the selection on the first matching artist, if any
         IntentFilter f = new IntentFilter();