Methods Summary |
---|
public android.support.v7.media.MediaRouteSelector | getRouteSelector()Gets the media route selector for filtering the routes that the user can select.
return mSelector;
|
public void | onAttachedToWindow()
super.onAttachedToWindow();
mAttachedToWindow = true;
mRouter.addCallback(mSelector, mCallback, MediaRouter.CALLBACK_FLAG_PERFORM_ACTIVE_SCAN);
refreshRoutes();
|
protected void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_LEFT_ICON);
setContentView(R.layout.mr_media_route_chooser_dialog);
setTitle(R.string.mr_media_route_chooser_title);
// Must be called after setContentView.
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
MediaRouterThemeHelper.getThemeResource(
getContext(), R.attr.mediaRouteOffDrawable));
mRoutes = new ArrayList<MediaRouter.RouteInfo>();
mAdapter = new RouteAdapter(getContext(), mRoutes);
mListView = (ListView)findViewById(R.id.media_route_list);
mListView.setAdapter(mAdapter);
mListView.setOnItemClickListener(mAdapter);
mListView.setEmptyView(findViewById(android.R.id.empty));
|
public void | onDetachedFromWindow()
mAttachedToWindow = false;
mRouter.removeCallback(mCallback);
super.onDetachedFromWindow();
|
public boolean | onFilterRoute(MediaRouter.RouteInfo route)Returns true if the route should be included in the list.
The default implementation returns true for enabled non-default routes that
match the selector. Subclasses can override this method to filter routes
differently.
return !route.isDefault() && route.isEnabled() && route.matchesSelector(mSelector);
|
public void | onFilterRoutes(java.util.List routes)Called to filter the set of routes that should be included in the list.
The default implementation iterates over all routes in the provided list and
removes those for which {@link #onFilterRoute} returns false.
for (int i = routes.size(); i-- > 0; ) {
if (!onFilterRoute(routes.get(i))) {
routes.remove(i);
}
}
|
public void | refreshRoutes()Refreshes the list of routes that are shown in the chooser dialog.
if (mAttachedToWindow) {
mRoutes.clear();
mRoutes.addAll(mRouter.getRoutes());
onFilterRoutes(mRoutes);
Collections.sort(mRoutes, RouteComparator.sInstance);
mAdapter.notifyDataSetChanged();
}
|
public void | setRouteSelector(android.support.v7.media.MediaRouteSelector selector)Sets the media route selector for filtering the routes that the user can select.
if (selector == null) {
throw new IllegalArgumentException("selector must not be null");
}
if (!mSelector.equals(selector)) {
mSelector = selector;
if (mAttachedToWindow) {
mRouter.removeCallback(mCallback);
mRouter.addCallback(selector, mCallback,
MediaRouter.CALLBACK_FLAG_PERFORM_ACTIVE_SCAN);
}
refreshRoutes();
}
|