Created
July 27, 2016 13:38
-
-
Save adrian-bl/05bdf344f83a681140fa14c12fdbe55f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/ch/blinkenlights/android/vanilla/FileSystemAdapter.java b/src/ch/blinkenlights/android/vanilla/FileSystemAdapter.java | |
index 7f12879..6f96db0 100644 | |
--- a/src/ch/blinkenlights/android/vanilla/FileSystemAdapter.java | |
+++ b/src/ch/blinkenlights/android/vanilla/FileSystemAdapter.java | |
@@ -233,6 +233,10 @@ public class FileSystemAdapter | |
mLimiter = limiter; | |
} | |
+ public void setHighlightedId(long id) { | |
+ // noop | |
+ } | |
+ | |
@Override | |
public Limiter getLimiter() | |
{ | |
diff --git a/src/ch/blinkenlights/android/vanilla/LibraryAdapter.java b/src/ch/blinkenlights/android/vanilla/LibraryAdapter.java | |
index 258874f..533040c 100644 | |
--- a/src/ch/blinkenlights/android/vanilla/LibraryAdapter.java | |
+++ b/src/ch/blinkenlights/android/vanilla/LibraryAdapter.java | |
@@ -74,6 +74,8 @@ public interface LibraryAdapter extends ListAdapter { | |
*/ | |
void setFilter(String filter); | |
+ void setHighlightedId(long id); | |
+ | |
/** | |
* Retrieve the data for this adapter. The data must be set with | |
* {@link LibraryAdapter#commitQuery(Object)} before it takes effect. | |
diff --git a/src/ch/blinkenlights/android/vanilla/LibraryPagerAdapter.java b/src/ch/blinkenlights/android/vanilla/LibraryPagerAdapter.java | |
index f73bfee..5ff5686 100644 | |
--- a/src/ch/blinkenlights/android/vanilla/LibraryPagerAdapter.java | |
+++ b/src/ch/blinkenlights/android/vanilla/LibraryPagerAdapter.java | |
@@ -124,6 +124,10 @@ public class LibraryPagerAdapter | |
*/ | |
private static AdaperPositionLruCache sLruAdapterPos; | |
/** | |
+ * The currently playing song, may be null | |
+ */ | |
+ private Song mCurrentSong; | |
+ /** | |
* The adapter of the currently visible list. | |
*/ | |
private LibraryAdapter mCurrentAdapter; | |
@@ -360,6 +364,7 @@ public class LibraryPagerAdapter | |
loadSortOrder((MediaAdapter)adapter); | |
adapter.setFilter(mFilter); | |
+ adapter.setHighlightedId(MediaUtils.getCurrentIdForType(mCurrentSong, type)); | |
mAdapters[type] = adapter; | |
mLists[type] = view; | |
@@ -856,6 +861,8 @@ public class LibraryPagerAdapter | |
* @param song song that is currently playing, can be null | |
*/ | |
public void onSongChange(Song song) { | |
+ mCurrentSong = song; | |
+ | |
if (mCurrentPage == -1) // no page active, nothing to do | |
return; | |
@@ -868,6 +875,12 @@ public class LibraryPagerAdapter | |
if (id == -1) // unknown type | |
return; | |
+ for (LibraryAdapter adapter : mAdapters) { | |
+ if (adapter != null) | |
+ adapter.setHighlightedId(MediaUtils.getCurrentIdForType(mCurrentSong, adapter.getMediaType())); | |
+ } | |
+ | |
+ | |
// scroll to song on song change if opted-in | |
SharedPreferences sharedPrefs = PlaybackService.getSettings(mActivity); | |
boolean shouldScroll = sharedPrefs.getBoolean(PrefKeys.ENABLE_SCROLL_TO_SONG, PrefDefaults.ENABLE_SCROLL_TO_SONG); | |
diff --git a/src/ch/blinkenlights/android/vanilla/MediaAdapter.java b/src/ch/blinkenlights/android/vanilla/MediaAdapter.java | |
index 124d5d2..930a245 100644 | |
--- a/src/ch/blinkenlights/android/vanilla/MediaAdapter.java | |
+++ b/src/ch/blinkenlights/android/vanilla/MediaAdapter.java | |
@@ -157,6 +157,8 @@ public class MediaAdapter | |
*/ | |
private List<SectionIndex> mAlphabet = new ArrayList<>(512); | |
+ private long mHighlightedId; | |
+ | |
/** | |
* Construct a MediaAdapter representing the given <code>type</code> of | |
* media. | |
@@ -283,6 +285,11 @@ public class MediaAdapter | |
mConstraint = filter; | |
} | |
+ public void setHighlightedId(long id) { | |
+ mHighlightedId = id; | |
+ notifyDataSetChanged(); | |
+ } | |
+ | |
/** | |
* Build the query to be run with runQuery(). | |
* | |
@@ -553,6 +560,7 @@ public class MediaAdapter | |
} | |
row.getCoverView().setCover(mCoverCacheType, cacheId, holder.title); | |
+ row.highlightRow(mHighlightedId == holder.id); | |
return row; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment