diff options
author | linus_lee <llee@cyngn.com> | 2014-11-04 17:52:36 -0800 |
---|---|---|
committer | linus_lee <llee@cyngn.com> | 2014-11-20 12:51:37 -0800 |
commit | d3feca9c173b999d663dd861bb369e7ce9b6b564 (patch) | |
tree | ba844349f3a9033b4a91aeb54d78c547e102ba72 /src | |
parent | 38df2d887b42c6af8d363a65dfef5d6ba3a1e7ae (diff) | |
download | android_packages_apps_Eleven-d3feca9c173b999d663dd861bb369e7ce9b6b564.tar.gz android_packages_apps_Eleven-d3feca9c173b999d663dd861bb369e7ce9b6b564.tar.bz2 android_packages_apps_Eleven-d3feca9c173b999d663dd861bb369e7ce9b6b564.zip |
Eleven: Make the adapter changes refresh not jump to the top of the list
https://cyanogen.atlassian.net/browse/MUSIC-122
https://cyanogen.atlassian.net/browse/MUSIC-130
Change-Id: I6216a84eb13d47b1b6a68fef2b698efebf677d9f
Diffstat (limited to 'src')
-rw-r--r-- | src/com/cyngn/eleven/ui/fragments/PlaylistDetailFragment.java | 8 | ||||
-rw-r--r-- | src/com/cyngn/eleven/ui/fragments/QueueFragment.java | 5 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/com/cyngn/eleven/ui/fragments/PlaylistDetailFragment.java b/src/com/cyngn/eleven/ui/fragments/PlaylistDetailFragment.java index 8e13067..b1e7a04 100644 --- a/src/com/cyngn/eleven/ui/fragments/PlaylistDetailFragment.java +++ b/src/com/cyngn/eleven/ui/fragments/PlaylistDetailFragment.java @@ -150,6 +150,7 @@ public class PlaylistDetailFragment extends FadingBarFragment implements @Override protected void removeFromPlaylist() { mAdapter.remove(mSong); + mAdapter.buildCache(); mAdapter.notifyDataSetChanged(); MusicUtils.removeFromPlaylist(getActivity(), mSong.mSongId, mPlaylistId); getLoaderManager().restartLoader(LOADER, null, PlaylistDetailFragment.this); @@ -326,12 +327,17 @@ public class PlaylistDetailFragment extends FadingBarFragment implements // show the header container mHeaderContainer.setVisibility(View.VISIBLE); + // pause notifying the adapter and make changes before re-enabling it so that the list + // view doesn't reset to the top of the list + mAdapter.setNotifyOnChange(false); // Start fresh mAdapter.unload(); // Return the correct count mAdapter.addAll(data); // build the cache mAdapter.buildCache(); + // re-enable the notify by calling notify dataset changes + mAdapter.notifyDataSetChanged(); // set the number of songs String numberOfSongs = MusicUtils.makeLabel(getActivity(), R.plurals.Nsongs, data.size()); @@ -358,8 +364,6 @@ public class PlaylistDetailFragment extends FadingBarFragment implements @Override public void restartLoader() { - // unload the adapter - this will also get the loading progress bar to show - mAdapter.unload(); lookupName(); // playlist name may have changed if(mPlaylistName == null) { // if name is null, we've been deleted, so close the this fragment diff --git a/src/com/cyngn/eleven/ui/fragments/QueueFragment.java b/src/com/cyngn/eleven/ui/fragments/QueueFragment.java index d47dd88..87c5f6c 100644 --- a/src/com/cyngn/eleven/ui/fragments/QueueFragment.java +++ b/src/com/cyngn/eleven/ui/fragments/QueueFragment.java @@ -358,6 +358,9 @@ public class QueueFragment extends Fragment implements LoaderCallbacks<List<Song */ @Override public void onLoadFinished(final Loader<List<Song>> loader, final List<Song> data) { + // pause notifying the adapter and make changes before re-enabling it so that the list + // view doesn't reset to the top of the list + mAdapter.setNotifyOnChange(false); mAdapter.unload(); // Start fresh if (data.isEmpty()) { @@ -372,6 +375,8 @@ public class QueueFragment extends Fragment implements LoaderCallbacks<List<Song // Set the currently playing audio mAdapter.setCurrentQueuePosition(MusicUtils.getQueuePosition()); } + // re-enable the notify by calling notify dataset changes + mAdapter.notifyDataSetChanged(); } /** |