diff options
author | Adam Powell <adamp@google.com> | 2012-06-21 15:29:40 -0700 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2012-06-21 15:29:40 -0700 |
commit | f7e0a328c939fa61792d4b685e8f9047a3a0ad90 (patch) | |
tree | 88450230f76173ebc36c34136d5177426eb0e920 | |
parent | 89c6bec3218d2f3f6d9fbe04fe2936021440ea80 (diff) | |
download | frameworks_base-f7e0a328c939fa61792d4b685e8f9047a3a0ad90.zip frameworks_base-f7e0a328c939fa61792d4b685e8f9047a3a0ad90.tar.gz frameworks_base-f7e0a328c939fa61792d4b685e8f9047a3a0ad90.tar.bz2 |
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
-rw-r--r-- | core/java/android/app/MediaRouteButton.java | 10 |
1 files 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++; + } } } |