Methods Summary |
---|
private void | ensureRouteSelector()
if (mSelector == null) {
Bundle args = getArguments();
if (args != null) {
mSelector = MediaRouteSelector.fromBundle(args.getBundle(ARGUMENT_SELECTOR));
}
if (mSelector == null) {
mSelector = MediaRouteSelector.EMPTY;
}
}
|
private void | ensureRouter()
if (mRouter == null) {
mRouter = MediaRouter.getInstance(getActivity());
}
|
public android.support.v7.media.MediaRouter | getMediaRouter()Gets the media router instance.
ensureRouter();
return mRouter;
|
public android.support.v7.media.MediaRouteSelector | getRouteSelector()Gets the media route selector for filtering the routes to be discovered.
ensureRouteSelector();
return mSelector;
|
public MediaRouter.Callback | onCreateCallback()Called to create the {@link android.support.v7.media.MediaRouter.Callback callback}
that will be registered.
The default callback does nothing. The application may override this method to
supply its own callback.
return new MediaRouter.Callback() { };
|
public int | onPrepareCallbackFlags()Called to prepare the callback flags that will be used when the
{@link android.support.v7.media.MediaRouter.Callback callback} is registered.
The default implementation returns {@link MediaRouter#CALLBACK_FLAG_REQUEST_DISCOVERY}.
return MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY;
|
public void | onStart()
super.onStart();
ensureRouteSelector();
ensureRouter();
mCallback = onCreateCallback();
if (mCallback != null) {
mRouter.addCallback(mSelector, mCallback, onPrepareCallbackFlags());
}
|
public void | onStop()
if (mCallback != null) {
mRouter.removeCallback(mCallback);
mCallback = null;
}
super.onStop();
|
public void | setRouteSelector(android.support.v7.media.MediaRouteSelector selector)Sets the media route selector for filtering the routes to be discovered.
This method must be called before the fragment is added.
if (selector == null) {
throw new IllegalArgumentException("selector must not be null");
}
ensureRouteSelector();
if (!mSelector.equals(selector)) {
mSelector = selector;
Bundle args = getArguments();
if (args == null) {
args = new Bundle();
}
args.putBundle(ARGUMENT_SELECTOR, selector.asBundle());
setArguments(args);
if (mCallback != null) {
mRouter.removeCallback(mCallback);
mRouter.addCallback(mSelector, mCallback, onPrepareCallbackFlags());
}
}
|