Exemplo n.º 1
1
  private Animator createHideItemAnimator(final View item) {
    final float dx = centerItem.getX() - item.getX();
    final float dy = centerItem.getY() - item.getY();

    Animator anim =
        ObjectAnimator.ofPropertyValuesHolder(
            item,
            AnimatorUtils.scaleX(1f, 0f),
            AnimatorUtils.scaleY(1f, 0f),
            AnimatorUtils.translationX(0f, dx),
            AnimatorUtils.translationY(0f, dy));

    anim.setInterpolator(new DecelerateInterpolator());
    anim.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            item.setTranslationX(0f);
            item.setTranslationY(0f);
          }
        });
    anim.setDuration(50);
    return anim;
  }
Exemplo n.º 2
0
  public void compatSetOrAnimatePlusCheckIcon(
      final ImageView imageView, boolean isCheck, boolean allowAnimate) {

    final int imageResId =
        isCheck
            ? R.drawable.add_schedule_button_icon_checked
            : R.drawable.add_schedule_button_icon_unchecked;

    if (imageView.getTag() != null) {
      if (imageView.getTag() instanceof Animator) {
        Animator anim = (Animator) imageView.getTag();
        anim.end();
        imageView.setAlpha(1f);
      }
    }

    if (allowAnimate && isCheck) {
      int duration = mActivity.getResources().getInteger(android.R.integer.config_shortAnimTime);

      Animator outAnimator = ObjectAnimator.ofFloat(imageView, View.ALPHA, 0f);
      outAnimator.setDuration(duration / 2);
      outAnimator.addListener(
          new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
              imageView.setImageResource(imageResId);
            }
          });

      AnimatorSet inAnimator = new AnimatorSet();
      outAnimator.setDuration(duration);
      inAnimator.playTogether(
          ObjectAnimator.ofFloat(imageView, View.ALPHA, 1f),
          ObjectAnimator.ofFloat(imageView, View.SCALE_X, 0f, 1f),
          ObjectAnimator.ofFloat(imageView, View.SCALE_Y, 0f, 1f));

      AnimatorSet set = new AnimatorSet();
      set.playSequentially(outAnimator, inAnimator);
      set.addListener(
          new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
              imageView.setTag(null);
            }
          });
      imageView.setTag(set);
      set.start();
    } else {
      mHandler.post(
          new Runnable() {
            @Override
            public void run() {
              imageView.setImageResource(imageResId);
            }
          });
    }
  }
Exemplo n.º 3
0
  private void init() {

    PropertyValuesHolder valueHolder_1 = PropertyValuesHolder.ofFloat("scaleX", 1f, 0.9f);
    PropertyValuesHolder valueHolder_2 = PropertyValuesHolder.ofFloat("scaleY", 1f, 0.9f);
    anim1 = ObjectAnimator.ofPropertyValuesHolder(this, valueHolder_1, valueHolder_2);
    anim1.setDuration(200);
    anim1.setInterpolator(new LinearInterpolator());

    PropertyValuesHolder valueHolder_3 = PropertyValuesHolder.ofFloat("scaleX", 0.9f, 1f);
    PropertyValuesHolder valueHolder_4 = PropertyValuesHolder.ofFloat("scaleY", 0.9f, 1f);
    anim2 = ObjectAnimator.ofPropertyValuesHolder(this, valueHolder_3, valueHolder_4);
    anim2.setDuration(200);
    anim2.setInterpolator(new LinearInterpolator());
  }
Exemplo n.º 4
0
  private void hideMenu(int cx, int cy, float startRadius, float endRadius) {
    List<Animator> animList = new ArrayList<>();

    for (int i = arcLayout.getChildCount() - 1; i >= 0; i--) {
      animList.add(createHideItemAnimator(arcLayout.getChildAt(i)));
    }

    animList.add(createHideItemAnimator(centerItem));

    Animator revealAnim = createCircularReveal(menuLayout, cx, cy, startRadius, endRadius);
    revealAnim.setInterpolator(new AccelerateDecelerateInterpolator());
    revealAnim.setDuration(200);
    revealAnim.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            menuLayout.setVisibility(View.INVISIBLE);
          }
        });

    animList.add(revealAnim);

    AnimatorSet animSet = new AnimatorSet();
    animSet.playSequentially(animList);
    animSet.start();
  }
Exemplo n.º 5
0
  // Layout showing effect(using CircularReveal)
  private void showLayout(int viewId, int viewId2) {
    final View myView = findViewById(viewId);
    View myView2 = findViewById(viewId2);

    if (android.os.Build.VERSION.SDK_INT > 20) {

      int finalRadius = Math.max(myView.getWidth(), myView.getHeight());

      int cx = (myView2.getLeft() + myView2.getRight()) / 2;
      int cy = (myView2.getTop() + myView2.getBottom()) / 2;

      Animator anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);
      anim.setDuration(500);

      anim.addListener(
          new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
              super.onAnimationEnd(animation);
              if (gameStatus == GAME_GOGAME) {
                gameStatus = GAME_WAITING;
              }
            }
          });

      myView.setVisibility(View.VISIBLE);
      myView.setAlpha(1);
      anim.start();
    } else {
      myView.setVisibility(View.VISIBLE);
      if (gameStatus == GAME_GOGAME) {
        gameStatus = GAME_WAITING;
      }
    }
  }
 public void animateCircularClip(int x, int y, boolean in, AnimatorListener listener) {
   if (mAnimator != null) {
     mAnimator.cancel();
   }
   final int w = mDetail.getWidth() - x;
   final int h = mDetail.getHeight() - y;
   int innerR = 0;
   if (x < 0 || w < 0 || y < 0 || h < 0) {
     innerR = Math.abs(x);
     innerR = Math.min(innerR, Math.abs(y));
     innerR = Math.min(innerR, Math.abs(w));
     innerR = Math.min(innerR, Math.abs(h));
   }
   int r = (int) Math.ceil(Math.sqrt(x * x + y * y));
   r = (int) Math.max(r, Math.ceil(Math.sqrt(w * w + y * y)));
   r = (int) Math.max(r, Math.ceil(Math.sqrt(w * w + h * h)));
   r = (int) Math.max(r, Math.ceil(Math.sqrt(x * x + h * h)));
   if (in) {
     mAnimator = ViewAnimationUtils.createCircularReveal(mDetail, x, y, innerR, r);
   } else {
     mAnimator = ViewAnimationUtils.createCircularReveal(mDetail, x, y, r, innerR);
   }
   mAnimator.setDuration((long) (mAnimator.getDuration() * 1.5));
   if (listener != null) {
     mAnimator.addListener(listener);
   }
   if (in) {
     mBackground.startTransition((int) (mAnimator.getDuration() * 0.6));
     mAnimator.addListener(mVisibleOnStart);
   } else {
     mDetail.postDelayed(mReverseBackground, (long) (mAnimator.getDuration() * 0.65));
     mAnimator.addListener(mGoneOnEnd);
   }
   mAnimator.start();
 }
Exemplo n.º 7
0
  private void animateLoad() {
    setTranslationY(500);
    setAlpha(0);

    final Animator translateAnimator = ObjectAnimator.ofFloat(this, "translationY", 0);
    translateAnimator.setDuration(400);

    final Animator alphaAnimator = ObjectAnimator.ofFloat(this, "alpha", 1);
    alphaAnimator.setStartDelay(200);
    alphaAnimator.setDuration(600);

    final AnimatorSet set = new AnimatorSet();
    set.playTogether(alphaAnimator, translateAnimator);
    set.setStartDelay(400);

    set.start();
  }
Exemplo n.º 8
0
  private void prepare(View view, FrameLayout FrameLayout) {
    int centerX = (view.getLeft() + view.getRight()) / 2;
    int centerY = (view.getTop() + view.getBottom()) / 2;
    finalRadius = (float) Math.hypot((double) centerX, (double) centerY);

    circularAnimator =
        ViewAnimationUtils.createCircularReveal(FrameLayout, centerX, centerY, 0, finalRadius);
    circularAnimator.setDuration(500);
  }
 private void showMessage(int duration) {
   if (duration > 0) {
     Animator anim = ObjectAnimator.ofFloat(this, "alpha", 1f);
     anim.setDuration(duration);
     anim.start();
   } else {
     setAlpha(1f);
   }
 }
 @Override
 public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
   if (FragmentUtils.disableAnimations) {
     Animator a = AnimatorInflater.loadAnimator(fa, nextAnim);
     a.setDuration(0);
     return a;
   } else {
     return super.onCreateAnimator(transit, enter, nextAnim);
   }
 }
Exemplo n.º 11
0
  /**
   * 根据当前scrollX的位置判断是展开还是折叠
   *
   * @param velocityX 如果不等于0那么这是一次fling事件,否则是一次ACTION_UP或者ACTION_CANCEL
   */
  private boolean smoothHorizontalExpandOrCollapse(float velocityX) {

    int scrollX = mTargetView.getScrollX();
    int scrollRange = getHorizontalRange();

    if (mExpandAndCollapseAnim != null) return false;

    int to = 0;
    int duration = DEFAULT_DURATION;

    if (velocityX == 0) {
      // 如果已经展一半,平滑展开
      if (scrollX > scrollRange / 2) {
        to = scrollRange;
      }
    } else {

      if (velocityX > 0) to = 0;
      else to = scrollRange;

      duration = (int) ((1.f - Math.abs(velocityX) / mMaxVelocity) * DEFAULT_DURATION);
    }

    if (to == scrollX) return false;

    mExpandAndCollapseAnim = ObjectAnimator.ofInt(mTargetView, "scrollX", to);
    mExpandAndCollapseAnim.setDuration(duration);
    mExpandAndCollapseAnim.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {
            mExpandAndCollapseAnim = null;
            if (isCollapsed()) mTargetView = null;

            Log.d(TAG, "onAnimationEnd");
          }

          @Override
          public void onAnimationCancel(Animator animation) {
            // onAnimationEnd(animation);
            mExpandAndCollapseAnim = null;

            Log.d(TAG, "onAnimationCancel");
          }

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    mExpandAndCollapseAnim.start();

    return true;
  }
  // testing animation class
  private void animateRevealShow(View viewRoot) {
    int cx = (viewRoot.getLeft() + viewRoot.getRight()) / 2;
    int cy = (viewRoot.getTop() + viewRoot.getBottom()) / 2;
    int finalRadius = Math.max(viewRoot.getWidth(), viewRoot.getHeight());

    Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, cx, cy, 0, finalRadius);
    viewRoot.setVisibility(View.VISIBLE);
    anim.setDuration(1000);
    anim.setInterpolator(new AccelerateInterpolator());
    anim.start();
  }
Exemplo n.º 13
0
 public void reverse(Animator animation, long time) {
   if (animation instanceof ObjectAnimator) {
     animation.removeAllListeners();
     animation.setDuration(time);
     ((ObjectAnimator) animation).reverse();
   } else if (animation instanceof AnimatorSet) {
     ArrayList<Animator> animations = ((AnimatorSet) animation).getChildAnimations();
     for (Animator animator : animations) {
       reverse(animator, time);
     }
   }
 }
Exemplo n.º 14
0
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  private void setMaterialLayout(View addButton) {
    addButton.setOutlineProvider(
        new ViewOutlineProvider() {
          @TargetApi(Build.VERSION_CODES.LOLLIPOP)
          @Override
          public void getOutline(View view, Outline outline) {
            int diameter = getResources().getDimensionPixelSize(R.dimen.button_diameter);
            outline.setOval(0, 0, diameter, diameter);
          }
        });
    addButton.setClipToOutline(true);

    addButton.setElevation(getResources().getDimension(R.dimen.elevation_low));

    // Dynamic add state list animator
    Animator press_animator =
        ObjectAnimator.ofFloat(
            addButton,
            "translationZ",
            getResources().getDimension(R.dimen.elevation_low),
            getResources().getDimension(R.dimen.elevation_high));
    press_animator.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));

    Animator normal_animator =
        ObjectAnimator.ofFloat(
            addButton,
            "translationZ",
            getResources().getDimension(R.dimen.elevation_high),
            getResources().getDimension(R.dimen.elevation_low));
    normal_animator.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));

    StateListAnimator animatorList = new StateListAnimator();
    animatorList.addState(new int[] {android.R.attr.state_pressed}, press_animator);
    animatorList.addState(new int[] {}, normal_animator);
    addButton.setStateListAnimator(animatorList);

    // Dnyamic setBackgroundResource
    addButton.setBackgroundResource(R.drawable.ripple_oval);
  }
  private void reveal(View sourceView, int colorRes, final AnimatorListener listener) {
    // Make reveal cover the display
    final RevealView revealView = new RevealView(this);
    revealView.setLayoutParams(mLayoutParams);
    revealView.setRevealColor(getResources().getColor(colorRes));
    mDisplayForeground.addView(revealView);

    final SupportAnimator revealAnimator;
    final int[] clearLocation = new int[2];
    if (sourceView != null) {
      sourceView.getLocationInWindow(clearLocation);
      clearLocation[0] += sourceView.getWidth() / 2;
      clearLocation[1] += sourceView.getHeight() / 2;
    } else {
      clearLocation[0] = mDisplayForeground.getWidth() / 2;
      clearLocation[1] = mDisplayForeground.getHeight() / 2;
    }
    final int revealCenterX = clearLocation[0] - revealView.getLeft();
    final int revealCenterY = clearLocation[1] - revealView.getTop();
    final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
    final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
    final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
    final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

    revealAnimator =
        ViewAnimationUtils.createCircularReveal(
            revealView, revealCenterX, revealCenterY, 0.0f, revealRadius);
    revealAnimator.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime));
    revealAnimator.addListener(listener);

    final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));
    alphaAnimator.addListener(
        new AnimationFinishedListener() {
          @Override
          public void onAnimationFinished() {
            mDisplayForeground.removeView(revealView);
          }
        });

    revealAnimator.addListener(
        new AnimationFinishedListener() {
          @Override
          public void onAnimationFinished() {
            play(alphaAnimator);
          }
        });
    play(revealAnimator);
  }
Exemplo n.º 16
0
  private void populateToolbarAnimations() {
    mSecurityButtonShowAnimator = new AnimatorSet();
    int securityIconButtonWidth =
        getResources().getDimensionPixelSize(R.dimen.location_bar_icon_width);
    Animator titleUrlTranslateAnimator =
        ObjectAnimator.ofFloat(mTitleUrlContainer, TRANSLATION_X, securityIconButtonWidth);
    titleUrlTranslateAnimator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
    titleUrlTranslateAnimator.setDuration(CUSTOM_TAB_TOOLBAR_SLIDE_DURATION_MS);

    Animator securityButtonAlphaAnimator = ObjectAnimator.ofFloat(mSecurityButton, ALPHA, 1);
    securityButtonAlphaAnimator.setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE);
    securityButtonAlphaAnimator.setDuration(CUSTOM_TAB_TOOLBAR_FADE_DURATION_MS);
    securityButtonAlphaAnimator.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationStart(Animator animation) {
            mSecurityButton.setVisibility(VISIBLE);
            mTitleUrlContainer.setTranslationX(0);
          }
        });

    mSecurityButtonShowAnimator.playSequentially(
        titleUrlTranslateAnimator, securityButtonAlphaAnimator);
  }
Exemplo n.º 17
0
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  private Animator circularRevealActivity(View rootView, int cx, int cy, boolean show) {
    float maxRadius = Math.max(rootView.getWidth(), rootView.getHeight());
    float startRadius = show ? 0 : maxRadius;
    float endRadius = show ? maxRadius : 0;

    // create the animator for this view (the start radius is zero)
    Animator circularReveal =
        ViewAnimationUtils.createCircularReveal(rootView, cx, cy, startRadius, endRadius);
    circularReveal.setDuration(animationTime);

    // make the view visible and start the animation
    rootView.setVisibility(View.VISIBLE);
    circularReveal.start();
    return circularReveal;
  }
Exemplo n.º 18
0
  /** 为 myView 自身添加显示隐藏的动画 */
  @SuppressLint("NewApi")
  private static void actionVisible(
      final boolean isShow, final View myView, float miniRadius, long durationMills) {
    // 版本判断
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
      if (isShow) myView.setVisibility(View.VISIBLE);
      else myView.setVisibility(View.INVISIBLE);
      return;
    }

    int cx = (myView.getLeft() + myView.getRight()) / 2;
    int cy = (myView.getTop() + myView.getBottom()) / 2;

    int w = myView.getWidth();
    int h = myView.getHeight();

    // 勾股定理 & 进一法
    int maxRadius = (int) Math.sqrt(w * w + h * h) + 1;

    float startRadius, endRadius;
    if (isShow) {
      // -< 从小到大
      startRadius = miniRadius;
      endRadius = maxRadius;
    } else {
      // >- 从大到校
      startRadius = maxRadius;
      endRadius = miniRadius;
    }

    Animator anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, startRadius, endRadius);
    myView.setVisibility(View.VISIBLE);
    anim.setDuration(durationMills);

    anim.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            // 无论显示还是隐藏,都应当在动画结束后执行。
            if (isShow) myView.setVisibility(View.VISIBLE);
            else myView.setVisibility(View.INVISIBLE);
          }
        });

    anim.start();
  }
Exemplo n.º 19
0
 public void showVoteColor(boolean showAnimation) {
   final Animator animator;
   switch (voteState) {
     case UP:
       {
         animator = VoteAnimation.voteUpTextColorAnimation(this);
         break;
       }
     default:
       animator = VoteAnimation.voteUpReverseTextColorAnimation(this);
       break;
   }
   if (!showAnimation) {
     animator.setDuration(0);
   }
   animator.start();
 }
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  private void contractLollipop(int x, int y, float startRadius, float endRadius) {

    Animator toolbarContractAnim =
        ViewAnimationUtils.createCircularReveal(mFabExpandLayout, x, y, startRadius, endRadius);
    toolbarContractAnim.setDuration(startAnimationDuration);

    toolbarContractAnim.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            contractAnimationEnd();
          }
        });

    toolbarContractAnim.start();
  }
  public void fadeFrame(Object caller, boolean takeControl, float alpha, int duration) {
    if (takeControl) {
      mBgAlphaController = caller;
    }

    if (mBgAlphaController != caller && mBgAlphaController != null) {
      return;
    }

    if (mFrameFade != null) {
      mFrameFade.cancel();
      mFrameFade = null;
    }
    PropertyValuesHolder bgAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", alpha);
    mFrameFade = ObjectAnimator.ofPropertyValuesHolder(this, bgAlpha);
    mFrameFade.setDuration(duration);
    mFrameFade.start();
  }
Exemplo n.º 22
0
  // Layout hiding effect(using CircularReveal)
  private void hideLayout(int viewId, int viewId2) {

    final View myView = findViewById(viewId);
    View myView2 = findViewById(viewId2);

    if (android.os.Build.VERSION.SDK_INT > 20) {

      int initialRadius = myView.getWidth();

      int cx = (myView2.getLeft() + myView2.getRight()) / 2;
      int cy = (myView2.getTop() + myView2.getBottom()) / 2;

      Animator anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, initialRadius, 0);
      // anim.setStartDelay(200);
      anim.setDuration(500);

      anim.addListener(
          new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
              super.onAnimationEnd(animation);
              myView.setVisibility(View.INVISIBLE);
              if (gameStatus == GAME_LOADING) showMenu();
              else if (gameStatus == GAME_GOMENU) {
                hideView(R.id.back);
                hideView(R.id.restart);
                hideView(R.id.share);
                gameStatus = GAME_MENU;
              }
            }
          });

      anim.start();
    } else {
      myView.setVisibility(View.INVISIBLE);
      if (gameStatus == GAME_LOADING) showMenu();
      else if (gameStatus == GAME_GOMENU) {
        hideView(R.id.back);
        hideView(R.id.restart);
        hideView(R.id.share);
        gameStatus = GAME_MENU;
      }
    }
  }
Exemplo n.º 23
0
  private void clearAnimation() {
    final Animator startAnimator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      final int revealSize = resultContainerView.getWidth();
      final int[] location = new int[2];
      deleteButton.getLocationInWindow(location);
      final int centerX = location[0] + deleteButton.getWidth() / 2;
      startAnimator =
          ViewAnimationUtils.createCircularReveal(
              revealView, centerX, resultContainerView.getHeight(), 0, revealSize);
    } else {
      startAnimator =
          ObjectAnimator.ofFloat(
              revealView, View.TRANSLATION_Y, resultContainerView.getHeight(), 0);
    }
    startAnimator.setDuration(ANIMATION_DURATION_CLEAR_START);

    final Animator endAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 1, 0);

    final AnimatorSet animator = new AnimatorSet();
    animator.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {
            revealView.setVisibility(View.VISIBLE);
          }

          @Override
          public void onAnimationEnd(Animator animation) {
            revealView.setVisibility(View.GONE);
            revealView.setAlpha(1);
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    animator.playSequentially(startAnimator, endAnimator);
    animator.start();
  }
 private void animateActionButtonVisibility(final boolean videoExist) {
   ActionButton videoBtn = binding.playVideoBtn;
   videoBtn.setEnabled(videoExist);
   Runnable r =
       () -> {
         // Button alpha may change during transition, we may have to wait until its end
         // to check its state.
         Timber.w("Action btn alpha: " + videoBtn.getAlpha());
         boolean actionBtnShouldAnimate =
             (videoExist && videoBtn.getAlpha() != 1) || (!videoExist && videoBtn.getAlpha() != 0);
         if (!actionBtnShouldAnimate) {
           return;
         }
         Animator alphaAnimator = AnimatorUtils.getAlphaAnimator(videoBtn, !videoExist);
         alphaAnimator.setDuration(600);
         alphaAnimator.start();
       };
   // Wait just in case transition is still in progress.
   videoBtn.postDelayed(r, ACTION_BUTTON_VISIBILITY_ANIM_DELAY);
 }
Exemplo n.º 25
0
  private void showMenu(int cx, int cy, float startRadius, float endRadius) {
    menuLayout.setVisibility(View.VISIBLE);

    List<Animator> animList = new ArrayList<>();

    Animator revealAnim = createCircularReveal(menuLayout, cx, cy, startRadius, endRadius);
    revealAnim.setInterpolator(new AccelerateDecelerateInterpolator());
    revealAnim.setDuration(200);

    animList.add(revealAnim);
    animList.add(createShowItemAnimator(centerItem));

    for (int i = 0, len = arcLayout.getChildCount(); i < len; i++) {
      animList.add(createShowItemAnimator(arcLayout.getChildAt(i)));
    }

    AnimatorSet animSet = new AnimatorSet();
    animSet.playSequentially(animList);
    animSet.start();
  }
Exemplo n.º 26
0
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  public static void setAnimation(View viewToAnimate, int position) {
    try {
      if (position >= Reddit.lastposition.get(Reddit.currentPosition) - 1 && Reddit.animation) {
        int cx = viewToAnimate.getWidth() / 2;
        int cy = viewToAnimate.getHeight() / 2;
        int finalRadius = Math.max(viewToAnimate.getWidth(), viewToAnimate.getHeight());

        final Animator anim =
            ViewAnimationUtils.createCircularReveal(viewToAnimate, cx, cy, 0, finalRadius);
        anim.setDuration(Reddit.enter_animation_time);
        anim.setInterpolator(new FastOutSlowInInterpolator());
        viewToAnimate.setVisibility(View.VISIBLE);
        anim.start();
        Reddit.lastposition.set(
            Reddit.currentPosition, Reddit.lastposition.get(Reddit.currentPosition) + 1);
      }
    } catch (IndexOutOfBoundsException e) {
      fixSliding(Reddit.currentPosition);
    }
  }
 private void hideMessage(int duration, boolean thenUpdate) {
   if (duration > 0) {
     Animator anim = ObjectAnimator.ofFloat(this, "alpha", 0f);
     anim.setDuration(duration);
     if (thenUpdate) {
       anim.addListener(
           new AnimatorListenerAdapter() {
             @Override
             public void onAnimationEnd(Animator animation) {
               update();
             }
           });
     }
     anim.start();
   } else {
     setAlpha(0f);
     if (thenUpdate) {
       update();
     }
   }
 }
Exemplo n.º 28
0
  private Animator createShowItemAnimator(View item) {
    float dx = centerItem.getX() - item.getX();
    float dy = centerItem.getY() - item.getY();

    item.setScaleX(0f);
    item.setScaleY(0f);
    item.setTranslationX(dx);
    item.setTranslationY(dy);

    Animator anim =
        ObjectAnimator.ofPropertyValuesHolder(
            item,
            AnimatorUtils.scaleX(0f, 1f),
            AnimatorUtils.scaleY(0f, 1f),
            AnimatorUtils.translationX(dx, 0f),
            AnimatorUtils.translationY(dy, 0f));

    anim.setInterpolator(new DecelerateInterpolator());
    anim.setDuration(50);
    return anim;
  }
Exemplo n.º 29
0
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  public static void revealHide(
      final Context context,
      int finalRadius,
      final View view,
      @ColorRes final int colorRes,
      @NonNull final OnRevealAnimationListener onRevealAnimationListener) {
    // previously invisible view

    // get the center for the clipping circle
    int cx = (view.getLeft() + view.getRight()) / 2;
    int cy = (view.getTop() + view.getBottom()) / 2;

    // get the final radius for the clipping circle
    int startRadius = Math.max(view.getWidth(), view.getHeight());

    // create the animator for this view (the start radius is zero)
    Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, startRadius, finalRadius);
    anim.setDuration(500);
    anim.setInterpolator(new AccelerateDecelerateInterpolator());
    anim.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            onRevealAnimationListener.onAnimationStart();
            view.setBackgroundColor(ContextCompat.getColor(context, colorRes));
          }

          @Override
          public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            // make the view visible and start the animation
            view.setVisibility(View.INVISIBLE);
            onRevealAnimationListener.onAnimationEnd();
          }
        });
    anim.start();
  }
  @SuppressLint("NewApi")
  private void createReveal(final View myView) {

    // get the center for the clipping circle
    int cx = (myView.getWidth()) / 2;
    int cy = (myView.getHeight()) / 2;

    // get the final radius for the clipping circle
    int finalRadius = Math.max(myView.getWidth(), myView.getHeight());

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
      Animator animator =
          android.view.ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);
      animator.setDuration(800);
      animator.start();
    } else {
      SupportAnimator animator =
          ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);
      animator.setInterpolator(new AccelerateDecelerateInterpolator());
      animator.setDuration(800);
      animator.start();
    }
  }