@Override public void onDetachedFromWindow() { mAttachedToWindow = false; if (!mSelector.isEmpty()) { mRouter.removeCallback(mCallback); } super.onDetachedFromWindow(); }
/** * Sets the media route selector for filtering the routes that the user can select using the media * route chooser dialog. * * @param selector The selector, must not be null. */ public void setRouteSelector(MediaRouteSelector selector) { if (selector == null) { throw new IllegalArgumentException("selector must not be null"); } if (!mSelector.equals(selector)) { if (mAttachedToWindow) { if (!mSelector.isEmpty()) { mRouter.removeCallback(mCallback); } if (!selector.isEmpty()) { mRouter.addCallback(selector, mCallback); } } mSelector = selector; refreshRoute(); } }