Fixed duplicate routes being added on activity resume.

This commit is contained in:
Felix Ableitner 2014-01-04 03:54:13 +01:00
parent 3b7bc513ad
commit 002934b2a1

View file

@ -132,7 +132,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
/** /**
* Selects remote playback route category. * Selects remote playback route category.
*/ */
public RouteFragment() { public RouteFragment() {
MediaRouteSelector mSelector = new MediaRouteSelector.Builder() MediaRouteSelector mSelector = new MediaRouteSelector.Builder()
.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK) .addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
.build(); .build();
@ -230,10 +230,13 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
@Override @Override
public Callback onCreateCallback() { public Callback onCreateCallback() {
return new MediaRouter.Callback() { return new MediaRouter.Callback() {
@Override @Override
public void onRouteAdded(MediaRouter router, RouteInfo route) { public void onRouteAdded(MediaRouter router, RouteInfo route) {
for (int i = 0; i < mRouteAdapter.getCount(); i++) {
if (mRouteAdapter.getItem(i).getId().equals(route.getId()))
return;
}
mRouteAdapter.add(route); mRouteAdapter.add(route);
} }