Search in sources :

Example 1 with MediaRouteControllerDialogFragment

use of android.support.v7.app.MediaRouteControllerDialogFragment 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 MediaRouteControllerDialogFragment

use of android.support.v7.app.MediaRouteControllerDialogFragment in project AndroidChromium by JackyAndroid.

the class RemoteMediaPlayerController method showMediaRouteControlDialog.

private void showMediaRouteControlDialog(Activity activity) {
    FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager();
    if (fm == null) {
        throw new IllegalStateException("The activity must be a subclass of FragmentActivity");
    }
    MediaRouteDialogFactory factory = new MediaRouteControllerDialogFactory();
    if (fm.findFragmentByTag("android.support.v7.mediarouter:MediaRouteControllerDialogFragment") != null) {
        Log.w(TAG, "showDialog(): Route controller dialog already showing!");
        return;
    }
    MediaRouteControllerDialogFragment f = factory.onCreateControllerDialogFragment();
    f.show(fm, "android.support.v7.mediarouter:MediaRouteControllerDialogFragment");
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) MediaRouteDialogFactory(android.support.v7.app.MediaRouteDialogFactory) FragmentActivity(android.support.v4.app.FragmentActivity) MediaRouteControllerDialogFragment(android.support.v7.app.MediaRouteControllerDialogFragment)

Example 3 with MediaRouteControllerDialogFragment

use of android.support.v7.app.MediaRouteControllerDialogFragment in project AndroidChromium by JackyAndroid.

the class RemoteMediaPlayerController method showMediaRouteControlDialog.

private void showMediaRouteControlDialog(MediaStateListener player, Activity activity) {
    FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager();
    if (fm == null) {
        throw new IllegalStateException("The activity must be a subclass of FragmentActivity");
    }
    MediaRouteDialogFactory factory = new MediaRouteControllerDialogFactory(player);
    if (fm.findFragmentByTag("android.support.v7.mediarouter:MediaRouteControllerDialogFragment") != null) {
        Log.w(TAG, "showDialog(): Route controller dialog already showing!");
        return;
    }
    MediaRouteControllerDialogFragment f = factory.onCreateControllerDialogFragment();
    f.show(fm, "android.support.v7.mediarouter:MediaRouteControllerDialogFragment");
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) MediaRouteDialogFactory(android.support.v7.app.MediaRouteDialogFactory) FragmentActivity(android.support.v4.app.FragmentActivity) MediaRouteControllerDialogFragment(android.support.v7.app.MediaRouteControllerDialogFragment)

Aggregations

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