Esempio n. 1
0
  @Override
  public boolean onTouch(View v, MotionEvent event) {
    if (!mAttached) {
      return false;
    }
    // Ignore future touches
    mScreenshotView.setOnTouchListener(null);

    mPreAnimator.end();
    mCallback.onSendConfirmed();
    return true;
  }
  /**
   * Starts the transition of showing or hiding the mask. If showMask is true, the mask will be set
   * to be invisible then fade into hide the other views in this container. If showMask is false,
   * the mask will be set to be hide other views initially. Then, the other views in this container
   * will be revealed.
   */
  public void startMaskTransition(boolean showMask) {
    // Stop any animation that may still be running.
    if (mAnimator != null && mAnimator.isRunning()) {
      mAnimator.end();
    }

    mMaskingView.setVisibility(View.VISIBLE);
    if (showMask) {
      mAnimator = ObjectAnimator.ofFloat(mMaskingView, View.ALPHA, 0.0f, 1.0f);
      mAnimator.start();
    } else {
      // asked to hide the view
      mAnimator = ObjectAnimator.ofFloat(mMaskingView, View.ALPHA, 1.0f, 0.0f);
      mAnimator.start();
    }
  }
  /** 执行反向动画将其隐藏 */
  private void doReverseAnimation() {
    if (Build.VERSION.SDK_INT < 11) {
      sv_bottom_content.setVisibility(View.GONE);
      ll_full_screen.setVisibility(View.GONE);
    } else {
      // 如果弹出动画还在执行,则直接将弹出动画的值置为最终值,代表该动画结束,接着直接进行收进动画
      popAnimation.end();
      // 避免用户连续快速点击造成短时间内执行两次收进动画,此处进行判断
      if (reverseAnimation != null && reverseAnimation.isRunning()) {
        return;
      }
      if (reverseAnimation == null) {
        reverseAnimation =
            ObjectAnimator.ofInt(sv_bottom_content, "bottomMargin", 0, -scrollViewMeasureHeight);
        reverseAnimation.addUpdateListener(
            new ValueAnimator.AnimatorUpdateListener() {
              @Override
              public void onAnimationUpdate(ValueAnimator animation) {
                int value = (Integer) animation.getAnimatedValue();
                RelativeLayout.LayoutParams params =
                    (RelativeLayout.LayoutParams) sv_bottom_content.getLayoutParams();
                params.bottomMargin = value;
                sv_bottom_content.setLayoutParams(params);
                ((View) (sv_bottom_content.getParent())).invalidate();
                if (value <= -scrollViewMeasureHeight) {
                  sv_bottom_content.setVisibility(View.GONE);
                }

                ll_full_screen.setAlpha(
                    (float)
                        (((scrollViewMeasureHeight + value) * 1.0)
                            / (scrollViewMeasureHeight * 1.0)));
                if (ll_full_screen.getAlpha() <= 0) {
                  ll_full_screen.setVisibility(View.GONE);
                }
              }
            });
        reverseAnimation.setDuration(500);
      }
      reverseAnimation.start();
    }
  }
  /** 用来显示该popwindow,保证在调用该方法之前已经调用{@link #addItemToBottomPopWindow(int, int, String)}方法 */
  protected void showBottomPopWindow() {
    if (Build.VERSION.SDK_INT >= 11) {
      // 如果上次的动画还在执行,直接停止
      if (reverseAnimation != null) {
        reverseAnimation.end();
      }
      sv_bottom_content.setVisibility(View.VISIBLE);
      ll_full_screen.setVisibility(View.VISIBLE);
      // 需要滚动到顶部
      sv_bottom_content.scrollTo(0, 0);
      if (popAnimation == null) {
        popAnimation =
            ObjectAnimator.ofInt(sv_bottom_content, "bottomMargin", -scrollViewMeasureHeight, 0);
        popAnimation.addUpdateListener(
            new ValueAnimator.AnimatorUpdateListener() {
              @Override
              public void onAnimationUpdate(ValueAnimator animation) {
                int value = (Integer) animation.getAnimatedValue();
                RelativeLayout.LayoutParams params =
                    (RelativeLayout.LayoutParams) sv_bottom_content.getLayoutParams();
                params.bottomMargin = value;
                sv_bottom_content.setLayoutParams(params);
                ((View) (sv_bottom_content.getParent())).invalidate();

                ll_full_screen.setAlpha(
                    (float)
                        (((scrollViewMeasureHeight + value) * 1.0)
                            / (scrollViewMeasureHeight * 1.0)));
              }
            });
        popAnimation.setDuration(500);
      }
      popAnimation.start();
    } else {
      ll_full_screen.setVisibility(View.VISIBLE);
      sv_bottom_content.setVisibility(View.VISIBLE);
      // 需要滚动到顶部
      sv_bottom_content.scrollTo(0, 0);
    }
  }
Esempio n. 5
0
  private void hideExtraViews() {
    if (toggleActivationView != null) {
      toggleActivationView.setVisibility(View.GONE);
    }
    if (analogReadView != null) {
      analogReadView.setVisibility(View.GONE);
    }
    if (analogWriteView != null) {
      analogWriteView.setVisibility(View.GONE);
    }
    if (digitalWriteView != null) {
      digitalWriteView.setVisibility(View.GONE);
    }
    if (digitalReadView != null) {
      digitalReadView.setVisibility(View.GONE);
    }

    if (pinBackgroundAnim != null) {
      pinBackgroundAnim.end();
    }
    View parent = (View) view.getParent();
    parent.setBackgroundColor(0);
  }
Esempio n. 6
0
  public void animateYourself() {
    final ViewGroup parent = (ViewGroup) view.getParent();

    if (pinBackgroundAnim != null) {
      pinBackgroundAnim.end();
      pinBackgroundAnim = null;
    }

    pinBackgroundAnim =
        (ObjectAnimator)
            AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_start);

    pinBackgroundAnim.setTarget(parent);
    pinBackgroundAnim.setEvaluator(new ArgbEvaluator());
    pinBackgroundAnim.addListener(
        new AnimatorListener() {

          @Override
          public void onAnimationStart(Animator animation) {
            // NO OP
          }

          @Override
          public void onAnimationRepeat(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {}

          @Override
          public void onAnimationCancel(Animator animation) {
            endAnimation = getCancelAnimator();
            endAnimation.start();
          }
        });
    pinBackgroundAnim.start();
  }