fix crash introduced with 71144b1f8ee91ddc07854366a7638a25d0238a26

mCurrentPage might not be initialized when setSong() is called, so we need to check for this.
This commit is contained in:
Adrian Ulrich 2016-07-23 15:01:28 +02:00
parent 3163505c78
commit d1a2bab400

View File

@ -857,15 +857,18 @@ public class LibraryPagerAdapter
* @param song song that is currently playing, can be null
*/
public void onSongChange(Song song) {
int type = mTabOrder[mCurrentPage];
long id = MediaUtils.getCurrentIdForType(song, type);
if (id == -1) // unknown type
if (mCurrentPage == -1) // no page active, nothing to do
return;
int type = mTabOrder[mCurrentPage];
ListView view = mLists[type];
if (view == null) // not initialized yet, nothing to do
return;
long id = MediaUtils.getCurrentIdForType(song, type);
if (id == -1) // unknown type
return;
// 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);