Search in sources :

Example 1 with MediaRouteChooserDialogFragment

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;
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) MediaRouteChooserDialogFragment(android.support.v7.app.MediaRouteChooserDialogFragment) MediaRouteControllerDialogFragment(android.support.v7.app.MediaRouteControllerDialogFragment) MediaRouter(android.support.v7.media.MediaRouter)

Example 2 with MediaRouteChooserDialogFragment

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");
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) MediaRouteDialogFactory(android.support.v7.app.MediaRouteDialogFactory) FragmentActivity(android.support.v4.app.FragmentActivity) MediaRouteChooserDialogFragment(android.support.v7.app.MediaRouteChooserDialogFragment)

Aggregations

FragmentManager (android.support.v4.app.FragmentManager)2 MediaRouteChooserDialogFragment (android.support.v7.app.MediaRouteChooserDialogFragment)2 FragmentActivity (android.support.v4.app.FragmentActivity)1 MediaRouteControllerDialogFragment (android.support.v7.app.MediaRouteControllerDialogFragment)1 MediaRouteDialogFactory (android.support.v7.app.MediaRouteDialogFactory)1 MediaRouter (android.support.v7.media.MediaRouter)1