예제 #1
0
  /**
   * Show the controller on screen. It will go away automatically after 'timeout' milliseconds of
   * inactivity.
   *
   * @param timeout The timeout in milliseconds. Use 0 to show the controller until hide() is
   *     called.
   */
  public void show(int timeout) {

    if (!mShowing && mAnchor != null) {
      setProgress();
      if (mPauseButton != null) {
        mPauseButton.requestFocus();
      }
      disableUnsupportedButtons();

      int[] anchorpos = new int[2];
      mAnchor.getLocationOnScreen(anchorpos);

      WindowManager.LayoutParams p = new WindowManager.LayoutParams();
      p.gravity = Gravity.TOP;
      p.width = mAnchor.getWidth();
      p.height = LayoutParams.WRAP_CONTENT;
      p.x = 0;
      p.y = anchorpos[1] + mAnchor.getHeight() - p.height;
      p.format = PixelFormat.TRANSLUCENT;
      p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
      p.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
      p.token = null;
      p.windowAnimations = 0; // android.R.style.DropDownAnimationDown;
      mWindowManager.addView(mDecor, p);
      mShowing = true;
    }
    updatePausePlay();

    // cause the progress bar to be updated even if mShowing
    // was already true.  This happens, for example, if we're
    // paused with the progress bar showing the user hits play.
    mHandler.sendEmptyMessage(SHOW_PROGRESS);

    Message msg = mHandler.obtainMessage(FADE_OUT);
    if (timeout != 0) {
      mHandler.removeMessages(FADE_OUT);
      mHandler.sendMessageDelayed(msg, timeout);
    }
  }
예제 #2
0
 @Override
 public void setEnabled(boolean enabled) {
   if (mPauseButton != null) {
     mPauseButton.setEnabled(enabled);
   }
   if (mFfwdButton != null) {
     mFfwdButton.setEnabled(enabled);
   }
   if (mRewButton != null) {
     mRewButton.setEnabled(enabled);
   }
   if (mNextButton != null) {
     mNextButton.setEnabled(enabled && mNextListener != null);
   }
   if (mPrevButton != null) {
     mPrevButton.setEnabled(enabled && mPrevListener != null);
   }
   if (mProgress != null) {
     mProgress.setEnabled(enabled);
   }
   disableUnsupportedButtons();
   super.setEnabled(enabled);
 }
  /**
   * Show the controller on screen. It will go away automatically after 'timeout' milliseconds of
   * inactivity.
   *
   * @param timeout The timeout in milliseconds. Use 0 to show the controller until hide() is
   *     called.
   */
  public void show(int timeout) {
    if (!mShowing && mAnchor != null) {
      setProgress();
      if (mPauseButton != null) {
        mPauseButton.requestFocus();
      }
      disableUnsupportedButtons();
      updateFloatingWindowLayout();
      mWindowManager.addView(mDecor, mDecorLayoutParams);
      mShowing = true;
    }
    updatePausePlay();

    // cause the progress bar to be updated even if mShowing
    // was already true.  This happens, for example, if we're
    // paused with the progress bar showing the user hits play.
    mHandler.sendEmptyMessage(SHOW_PROGRESS);

    if (timeout != 0 && !mAccessibilityManager.isTouchExplorationEnabled()) {
      mHandler.removeMessages(FADE_OUT);
      Message msg = mHandler.obtainMessage(FADE_OUT);
      mHandler.sendMessageDelayed(msg, timeout);
    }
  }