use of android.support.v7.app.MediaRouteChooserDialogFragment in project AntennaPod by AntennaPod.
the class SwitchableMediaRouteActionProvider method onPerformDefaultAction.
@Override
public boolean onPerformDefaultAction() {
if (!super.onPerformDefaultAction()) {
// there is no button, but we should still show the dialog if it's the case.
if (!isVisible()) {
return false;
}
FragmentManager fm = getFragmentManager();
if (fm == null) {
return false;
}
MediaRouter.RouteInfo route = MediaRouter.getInstance(getContext()).getSelectedRoute();
if (route.isDefault() || !route.matchesSelector(getRouteSelector())) {
if (fm.findFragmentByTag(CHOOSER_FRAGMENT_TAG) != null) {
Log.w(TAG, "showDialog(): Route chooser dialog already showing!");
return false;
}
MediaRouteChooserDialogFragment f = getDialogFactory().onCreateChooserDialogFragment();
f.setRouteSelector(getRouteSelector());
f.show(fm, CHOOSER_FRAGMENT_TAG);
} else {
if (fm.findFragmentByTag(CONTROLLER_FRAGMENT_TAG) != null) {
Log.w(TAG, "showDialog(): Route controller dialog already showing!");
return false;
}
MediaRouteControllerDialogFragment f = getDialogFactory().onCreateControllerDialogFragment();
f.show(fm, CONTROLLER_FRAGMENT_TAG);
}
return true;
} else {
return true;
}
}
use of android.support.v7.app.MediaRouteChooserDialogFragment in project AndroidChromium by JackyAndroid.
the class RemoteMediaPlayerController method showMediaRouteDialog.
private void showMediaRouteDialog(MediaStateListener player, MediaRouteController controller, Activity activity) {
FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager();
if (fm == null) {
throw new IllegalStateException("The activity must be a subclass of FragmentActivity");
}
MediaRouteDialogFactory factory = new MediaRouteChooserDialogFactory(player, controller, activity);
if (fm.findFragmentByTag("android.support.v7.mediarouter:MediaRouteChooserDialogFragment") != null) {
Log.w(TAG, "showDialog(): Route chooser dialog already showing!");
return;
}
MediaRouteChooserDialogFragment f = factory.onCreateChooserDialogFragment();
f.setRouteSelector(controller.buildMediaRouteSelector());
f.show(fm, "android.support.v7.mediarouter:MediaRouteChooserDialogFragment");
}
Aggregations