From f7e0a328c939fa61792d4b685e8f9047a3a0ad90 Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Thu, 21 Jun 2012 15:29:40 -0700 Subject: Allow ungrouping media routes when a group is the only alternate route Fix a MediaRouteButton bug where group item counts weren't taken into account when deciding whether to toggle between two available groups or show the chooser dialog. Change-Id: I6400ffd4cfe80c8072c5be360264b8ca91d71c41 --- core/java/android/app/MediaRouteButton.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/MediaRouteButton.java b/core/java/android/app/MediaRouteButton.java index 18713f5..5863ad0 100644 --- a/core/java/android/app/MediaRouteButton.java +++ b/core/java/android/app/MediaRouteButton.java @@ -25,6 +25,7 @@ import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.media.MediaRouter; +import android.media.MediaRouter.RouteGroup; import android.media.MediaRouter.RouteInfo; import android.util.AttributeSet; import android.util.Log; @@ -157,8 +158,13 @@ public class MediaRouteButton extends View { final int N = mRouter.getRouteCount(); int count = 0; for (int i = 0; i < N; i++) { - if ((mRouter.getRouteAt(i).getSupportedTypes() & mRouteTypes) != 0) { - count++; + final RouteInfo route = mRouter.getRouteAt(i); + if ((route.getSupportedTypes() & mRouteTypes) != 0) { + if (route instanceof RouteGroup) { + count += ((RouteGroup) route).getRouteCount(); + } else { + count++; + } } } -- cgit v1.1