Merge "Clean up behavior of type arguments for MediaRouter#getSelectedRoute" into jb-mr1.1-dev

This commit is contained in:
Adam Powell
2012-11-28 19:02:37 -08:00
committed by Android (Google) Code Review
3 changed files with 32 additions and 12 deletions

View File

@ -136,13 +136,14 @@ public class MediaRouteChooserDialogFragment extends DialogFragment {
if (mRouter == null) return;
final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes);
mVolumeIcon.setImageResource(
mVolumeIcon.setImageResource(selectedRoute == null ||
selectedRoute.getPlaybackType() == RouteInfo.PLAYBACK_TYPE_LOCAL ?
R.drawable.ic_audio_vol : R.drawable.ic_media_route_on_holo_dark);
mIgnoreSliderVolumeChanges = true;
if (selectedRoute.getVolumeHandling() == RouteInfo.PLAYBACK_VOLUME_FIXED) {
if (selectedRoute == null ||
selectedRoute.getVolumeHandling() == RouteInfo.PLAYBACK_VOLUME_FIXED) {
// Disable the slider and show it at max volume.
mVolumeSlider.setMax(1);
mVolumeSlider.setProgress(1);
@ -160,7 +161,8 @@ public class MediaRouteChooserDialogFragment extends DialogFragment {
if (mIgnoreSliderVolumeChanges) return;
final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes);
if (selectedRoute.getVolumeHandling() == RouteInfo.PLAYBACK_VOLUME_VARIABLE) {
if (selectedRoute != null &&
selectedRoute.getVolumeHandling() == RouteInfo.PLAYBACK_VOLUME_VARIABLE) {
final int maxVolume = selectedRoute.getVolumeMax();
newValue = Math.max(0, Math.min(newValue, maxVolume));
selectedRoute.requestSetVolume(newValue);
@ -652,14 +654,19 @@ public class MediaRouteChooserDialogFragment extends DialogFragment {
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && mVolumeSlider.isEnabled()) {
mRouter.getSelectedRoute(mRouteTypes).requestUpdateVolume(-1);
return true;
final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes);
if (selectedRoute != null) {
selectedRoute.requestUpdateVolume(-1);
return true;
}
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && mVolumeSlider.isEnabled()) {
mRouter.getSelectedRoute(mRouteTypes).requestUpdateVolume(1);
return true;
} else {
return super.onKeyDown(keyCode, event);
final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes);
if (selectedRoute != null) {
mRouter.getSelectedRoute(mRouteTypes).requestUpdateVolume(1);
return true;
}
}
return super.onKeyDown(keyCode, event);
}
public boolean onKeyUp(int keyCode, KeyEvent event) {