Added scrolling to current track on notification click.
This commit is contained in:
parent
86b6179ad0
commit
b06d889c10
3 changed files with 17 additions and 15 deletions
|
@ -182,8 +182,10 @@ public class MainActivity extends ActionBarActivity {
|
|||
*/
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
if (intent.getAction().equals("showRouteFragment"))
|
||||
if (intent.getAction().equals("showRouteFragment")) {
|
||||
mViewPager.setCurrentItem(1);
|
||||
mRouteFragment.scrollToCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -80,8 +80,8 @@ import com.github.nutomic.controldlna.utility.RouteAdapter;
|
|||
*
|
||||
*/
|
||||
public class RouteFragment extends MediaRouteDiscoveryFragment implements
|
||||
OnBackPressedListener, OnItemClickListener, OnClickListener,
|
||||
OnSeekBarChangeListener, OnScrollListener {
|
||||
OnBackPressedListener, OnItemClickListener, OnClickListener,
|
||||
OnSeekBarChangeListener, OnScrollListener {
|
||||
|
||||
private ListView mListView;
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
|
|||
mMediaRouterPlayService = (MediaRouterPlayServiceBinder) service;
|
||||
mMediaRouterPlayService.getService().setRouterFragment(RouteFragment.this);
|
||||
mPlaylistAdapter.add(mMediaRouterPlayService.getService().getPlaylist());
|
||||
receiveIsPlaying(mMediaRouterPlayService.getService().getCurrentTrack());
|
||||
scrollToCurrent();
|
||||
applyColors();
|
||||
RouteInfo currentRoute = mMediaRouterPlayService.getService().getCurrentRoute();
|
||||
if (currentRoute != null)
|
||||
|
@ -399,7 +399,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
|
|||
changePlayPauseState(false);
|
||||
} else {
|
||||
s.resume();
|
||||
mListView.smoothScrollToPosition(s.getCurrentTrack());
|
||||
scrollToCurrent();
|
||||
changePlayPauseState(true);
|
||||
}
|
||||
break;
|
||||
|
@ -532,15 +532,6 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
|
|||
: "0" + Integer.toString(seconds));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sent by MediaRouterPlayService when playback of a new track is started.
|
||||
*
|
||||
* @param track Index of the track in the playlist.
|
||||
*/
|
||||
public void receiveIsPlaying(int track) {
|
||||
mListView.smoothScrollToPosition(track);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives information from MediaRouterPlayService about playback status.
|
||||
*/
|
||||
|
@ -587,4 +578,13 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* When in playlist mode, scrolls to the item that is currently playing.
|
||||
*/
|
||||
public void scrollToCurrent() {
|
||||
mListView.smoothScrollToPosition(
|
||||
mMediaRouterPlayService.getService().getCurrentTrack());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -239,7 +239,7 @@ public class MediaRouterPlayService extends Service {
|
|||
.getFirstPropertyValue(DIDLObject.Property.UPNP.ALBUM_ART_URI.class));
|
||||
|
||||
if (mRouterFragment.get() != null)
|
||||
mRouterFragment.get().receiveIsPlaying(mCurrentTrack);
|
||||
mRouterFragment.get().scrollToCurrent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Reference in a new issue