android.support.v7.app.MediaRouteControllerDialogFragment Java Examples

The following examples show how to use android.support.v7.app.MediaRouteControllerDialogFragment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RemoteMediaPlayerController.java    From delion with Apache License 2.0 6 votes vote down vote up
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");
    }
 
Example #2
Source File: RemoteMediaPlayerController.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
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");
}
 
Example #3
Source File: RemoteMediaPlayerController.java    From 365browser with Apache License 2.0 6 votes vote down vote up
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");
}
 
Example #4
Source File: MediaRouteControllerDialogManager.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
protected DialogFragment openDialogInternal(FragmentManager fm) {
    if (fm.findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) return null;

    MediaRouteControllerDialogFragment fragment = new MediaRouteControllerDialogFragment() {
        final SystemVisibilitySaver mVisibilitySaver = new SystemVisibilitySaver();

        @Override
        public void onStart() {
            mVisibilitySaver.saveSystemVisibility(getActivity());
            super.onStart();
        }

        @Override
        public void onStop() {
            super.onStop();
            mVisibilitySaver.restoreSystemVisibility(getActivity());
        }

        @Override
        public void onDismiss(DialogInterface dialog) {
            delegate().onDialogCancelled();
            androidMediaRouter().removeCallback(mCallback);
            mDialogFragment = null;
            super.onDismiss(dialog);
        }
    };

    MediaRouteSelector selector = mediaSource().buildRouteSelector();
    if (selector == null) return null;

    androidMediaRouter().addCallback(selector, mCallback);

    fragment.show(fm, DIALOG_FRAGMENT_TAG);
    fm.executePendingTransactions();

    return fragment;
}
 
Example #5
Source File: SampleMediaRouterActivity.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Be sure to call the super class.
    super.onCreateOptionsMenu(menu);

    // Inflate the menu and configure the media router action provider.
    getMenuInflater().inflate(R.menu.sample_media_router_menu, menu);

    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider)MenuItemCompat.getActionProvider(mediaRouteMenuItem);
    mediaRouteActionProvider.setRouteSelector(mSelector);
    mediaRouteActionProvider.setDialogFactory(new MediaRouteDialogFactory() {
        @Override
        public MediaRouteControllerDialogFragment onCreateControllerDialogFragment() {
            return new MediaRouteControllerDialogFragment() {
                @Override
                public MediaRouteControllerDialog onCreateControllerDialog(
                        Context context, Bundle savedInstanceState) {
                    mControllerDialog = new SampleMediaRouteControllerDialog(
                            context, mSessionManager, mPlayer);
                    return mControllerDialog;
                }
            };
        }
    });

    // Return true to show the menu.
    return true;
}
 
Example #6
Source File: MediaRouteControllerDialogFactory.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public MediaRouteControllerDialogFragment onCreateControllerDialogFragment() {
    return new MediaRouteControllerDialogFragment();
}
 
Example #7
Source File: MediaRouteControllerDialogFactory.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public MediaRouteControllerDialogFragment onCreateControllerDialogFragment() {
    return new Fragment(mPlayer);
}
 
Example #8
Source File: MediaRouteControllerDialogFactory.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public MediaRouteControllerDialogFragment onCreateControllerDialogFragment() {
    return new Fragment(mPlayer);
}
 
Example #9
Source File: CustomMediaRouteDialogFactory.java    From Popeens-DSub with GNU General Public License v3.0 4 votes vote down vote up
@Override
public MediaRouteControllerDialogFragment onCreateControllerDialogFragment() {
	return new CustomMediaRouteControllerDialogFragment();
}