From 002934b2a1814e041b13e045182c16eafe138c3f Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sat, 4 Jan 2014 03:54:13 +0100 Subject: [PATCH] Fixed duplicate routes being added on activity resume. --- src/com/github/nutomic/controldlna/gui/RouteFragment.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/com/github/nutomic/controldlna/gui/RouteFragment.java b/src/com/github/nutomic/controldlna/gui/RouteFragment.java index 91f13da..d1c3e1c 100644 --- a/src/com/github/nutomic/controldlna/gui/RouteFragment.java +++ b/src/com/github/nutomic/controldlna/gui/RouteFragment.java @@ -132,7 +132,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements /** * Selects remote playback route category. */ - public RouteFragment() { + public RouteFragment() { MediaRouteSelector mSelector = new MediaRouteSelector.Builder() .addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK) .build(); @@ -230,10 +230,13 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements @Override public Callback onCreateCallback() { - return new MediaRouter.Callback() { @Override 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); }