@Override
  public void onAttachedToWindow() {
    super.onAttachedToWindow();

    mAttachedToWindow = true;
    if (!mSelector.isEmpty()) {
      mRouter.addCallback(mSelector, mCallback);
    }
    refreshRoute();
  }
  /**
   * 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();
    }
  }