Java Code Examples for android.animation.AnimatorSet#addListener()

The following examples show how to use android.animation.AnimatorSet#addListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DrawerLayoutContainer.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void closeDrawer(boolean fast) {
    cancelCurrentAnimation();
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(this, "drawerPosition", 0)
    );
    animatorSet.setInterpolator(new DecelerateInterpolator());
    if (fast) {
        animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * drawerPosition), 50));
    } else {
        animatorSet.setDuration(250);
    }
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            onDrawerAnimationEnd(false);
        }
    });
    animatorSet.start();
}
 
Example 2
Source File: SplashActivity.java    From ZhuanLan with Apache License 2.0 6 votes vote down vote up
private void animateImage() {
    ObjectAnimator animatorX = ObjectAnimator.ofFloat(mSplashImage, View.SCALE_X, 1f, SCALE_END);
    ObjectAnimator animatorY = ObjectAnimator.ofFloat(mSplashImage, View.SCALE_Y, 1f, SCALE_END);

    AnimatorSet set = new AnimatorSet();
    set.setDuration(ANIMATION_DURATION).play(animatorX).with(animatorY);
    set.start();

    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            MainActivity.start(SplashActivity.this);
            SplashActivity.this.finish();
        }
    });
}
 
Example 3
Source File: pagePrototype.java    From Android-Music-Player with MIT License 6 votes vote down vote up
public void open(final call Call, boolean from){
    int to = width;
    if(from){
        to = -width;
    }
    Set = new AnimatorSet();
    Set.setInterpolator(Ui.cd.TH);
    Set.playTogether(
            ObjectAnimator.ofFloat(this, "X", to, 0),
            ObjectAnimator.ofFloat(this, "Alpha", 100, 100)
    );
    Set.setDuration(0).start();
    Set.addListener(new animLis(){
        @Override
        public void onAnimationEnd(Animator animation) {
           Call.onCall(true);
            removeCatch();
        }
    });
}
 
Example 4
Source File: ChannelAdminLogActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void hideFloatingDateView(boolean animated) {
    if (floatingDateView.getTag() != null && !currentFloatingDateOnScreen && (!scrollingFloatingDate || currentFloatingTopIsNotMessage)) {
        floatingDateView.setTag(null);
        if (animated) {
            floatingDateAnimation = new AnimatorSet();
            floatingDateAnimation.setDuration(150);
            floatingDateAnimation.playTogether(ObjectAnimator.ofFloat(floatingDateView, "alpha", 0.0f));
            floatingDateAnimation.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    if (animation.equals(floatingDateAnimation)) {
                        floatingDateAnimation = null;
                    }
                }
            });
            floatingDateAnimation.setStartDelay(500);
            floatingDateAnimation.start();
        } else {
            if (floatingDateAnimation != null) {
                floatingDateAnimation.cancel();
                floatingDateAnimation = null;
            }
            floatingDateView.setAlpha(0.0f);
        }
    }
}
 
Example 5
Source File: AnimatedEditText.java    From AnimatedEditText with Apache License 2.0 6 votes vote down vote up
private void animatePopIn(final boolean reverse, AnimationEndListener listener) {
    float start = reverse ? getPaint().getTextSize() : 1;
    float end = reverse ? 1 : getPaint().getTextSize();
    ValueAnimator va = ValueAnimator.ofFloat(start, end);
    va.setInterpolator(new OvershootInterpolator());
    va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mAnimPaint.setTextSize((Float) animation.getAnimatedValue());
            AnimatedEditText.this.invalidate();
        }
    });
    mAnimSet = new AnimatorSet();
    if (listener != null) {
        mAnimSet.addListener(listener);
    }
    mAnimationsToPlay.clear();
    mAnimationsToPlay.add(va);
    if (mShouldAnimateCursor) {
        ValueAnimator animCursor = animateMoveCursor(reverse);
        mAnimationsToPlay.add(animCursor);
    }
    mAnimSet.playTogether(mAnimationsToPlay);
    mAnimSet.setDuration(200);
    mAnimSet.start();
}
 
Example 6
Source File: DrawerLayoutContainer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void closeDrawer(boolean fast)
{
    cancelCurrentAnimation();
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(this, "drawerPosition", 0)
    );
    animatorSet.setInterpolator(new DecelerateInterpolator());
    if (fast)
    {
        animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * drawerPosition), 50));
    }
    else
    {
        animatorSet.setDuration(300);
    }
    animatorSet.addListener(new AnimatorListenerAdapter()
    {
        @Override
        public void onAnimationEnd(Animator animator)
        {
            onDrawerAnimationEnd(false);
        }
    });
    animatorSet.start();
}
 
Example 7
Source File: AndroidUtilities.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public static void shakeView(final View view, final float x, final int num) {
    if (view == null) {
        return;
    }
    if (num == 6) {
        view.setTranslationX(0);
        return;
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(view, "translationX", dp(x)));
    animatorSet.setDuration(50);
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            shakeView(view, num == 5 ? 0 : -x, num + 1);
        }
    });
    animatorSet.start();
}
 
Example 8
Source File: PopupManager.java    From memory-game with Apache License 2.0 5 votes vote down vote up
public static void closePopup() {
	final RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container);
	int childCount = popupContainer.getChildCount();
	if (childCount > 0) {
		View background = null;
		View viewPopup = null;
		if (childCount == 1) {
			viewPopup = popupContainer.getChildAt(0);
		} else {
			background = popupContainer.getChildAt(0);
			viewPopup = popupContainer.getChildAt(1);
		}

		AnimatorSet animatorSet = new AnimatorSet();
		ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(viewPopup, "scaleX", 0f);
		ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(viewPopup, "scaleY", 0f);
		if (childCount > 1) {
			ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(background, "alpha", 0f);
			animatorSet.playTogether(scaleXAnimator, scaleYAnimator, alphaAnimator);
		} else {
			animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
		}
		animatorSet.setDuration(300);
		animatorSet.setInterpolator(new AccelerateInterpolator(2));
		animatorSet.addListener(new AnimatorListenerAdapter() {
			@Override
			public void onAnimationEnd(Animator animation) {
				popupContainer.removeAllViews();
			}
		});
		animatorSet.start();
	}
}
 
Example 9
Source File: CaptureLayout.java    From EasyPhotos with Apache License 2.0 5 votes vote down vote up
public void startTypeBtnAnimator() {
    //拍照录制结果后的动画
    if (this.iconLeft != 0)
        iv_custom_left.setVisibility(GONE);
    else
        btn_return.setVisibility(GONE);
    if (this.iconRight != 0)
        iv_custom_right.setVisibility(GONE);
    btn_capture.setVisibility(GONE);
    btn_cancel.setVisibility(VISIBLE);
    btn_confirm.setVisibility(VISIBLE);
    btn_cancel.setClickable(false);
    btn_confirm.setClickable(false);
    ObjectAnimator animator_cancel = ObjectAnimator.ofFloat(btn_cancel, "translationX", layout_width / 4, 0);
    ObjectAnimator animator_confirm = ObjectAnimator.ofFloat(btn_confirm, "translationX", -layout_width / 4, 0);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(animator_cancel, animator_confirm);
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            btn_cancel.setClickable(true);
            btn_confirm.setClickable(true);
        }
    });
    set.setDuration(200);
    set.start();
}
 
Example 10
Source File: VoIPActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void hideRetry() {
    if (retryAnim != null)
        retryAnim.cancel();
    retrying = false;
    //bottomButtons.setVisibility(View.VISIBLE);
    ObjectAnimator colorAnim;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44);
    } else {
        colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44);
        colorAnim.setEvaluator(new ArgbEvaluator());
    }
    AnimatorSet set = new AnimatorSet();
    set.playTogether(
            colorAnim,
            ObjectAnimator.ofFloat(endBtnIcon, "rotation", -135, 0),
            ObjectAnimator.ofFloat(endBtn, View.TRANSLATION_X, 0),
            ObjectAnimator.ofFloat(cancelBtn, View.ALPHA, 0)//,
            //ObjectAnimator.ofFloat(bottomButtons, View.ALPHA, 1)
    );
    set.setStartDelay(200);
    set.setDuration(300);
    set.setInterpolator(CubicBezierInterpolator.DEFAULT);
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            cancelBtn.setVisibility(View.GONE);
            endBtn.setEnabled(true);
            retryAnim = null;
        }
    });
    retryAnim = set;
    set.start();
}
 
Example 11
Source File: DefaultTransition.java    From magellan with Apache License 2.0 5 votes vote down vote up
@Override
public final void animate(View from, View to, NavigationType navType, Direction direction, final Callback callback) {
  AnimatorSet animator = createAnimator(from, to, navType, direction);
  animator.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      callback.onAnimationEnd();
    }
  });
  animator.start();
}
 
Example 12
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void hideRetry(){
    if(retryAnim!=null)
        retryAnim.cancel();
    retrying=false;
    //bottomButtons.setVisibility(View.VISIBLE);
    ObjectAnimator colorAnim;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44);
    } else {
        colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44);
        colorAnim.setEvaluator(new ArgbEvaluator());
    }
    AnimatorSet set=new AnimatorSet();
    set.playTogether(
            colorAnim,
            ObjectAnimator.ofFloat(endBtnIcon, "rotation", -135, 0),
            ObjectAnimator.ofFloat(endBtn, "translationX", 0),
            ObjectAnimator.ofFloat(cancelBtn, "alpha", 0)//,
            //ObjectAnimator.ofFloat(bottomButtons, "alpha", 1)
    );
    set.setStartDelay(200);
    set.setDuration(300);
    set.setInterpolator(CubicBezierInterpolator.DEFAULT);
    set.addListener(new AnimatorListenerAdapter(){
        @Override
        public void onAnimationEnd(Animator animation){
            cancelBtn.setVisibility(View.GONE);
            endBtn.setEnabled(true);
retryAnim=null;
        }
    });
    retryAnim=set;
    set.start();
}
 
Example 13
Source File: ItemAnimator.java    From FancyAccordionView with Apache License 2.0 5 votes vote down vote up
@Override
public void runPendingAnimations() {
    final AnimatorSet removeAnimatorSet = new AnimatorSet();
    removeAnimatorSet.playTogether(mRemoveAnimatorsList);
    mRemoveAnimatorsList.clear();

    final AnimatorSet addAnimatorSet = new AnimatorSet();
    addAnimatorSet.playTogether(mAddAnimatorsList);
    mAddAnimatorsList.clear();

    final AnimatorSet changeAnimatorSet = new AnimatorSet();
    changeAnimatorSet.playTogether(mChangeAnimatorsList);
    mChangeAnimatorsList.clear();

    final AnimatorSet moveAnimatorSet = new AnimatorSet();
    moveAnimatorSet.playTogether(mMoveAnimatorsList);
    mMoveAnimatorsList.clear();

    final AnimatorSet pendingAnimatorSet = new AnimatorSet();
    pendingAnimatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            animator.removeAllListeners();
            dispatchFinishedWhenDone();
        }
    });
    // Required order: removes, then changes & moves simultaneously, then additions. There are
    // redundant edges because changes or moves may be empty, causing the removes to incorrectly
    // play immediately.
    pendingAnimatorSet.play(removeAnimatorSet).before(changeAnimatorSet);
    pendingAnimatorSet.play(removeAnimatorSet).before(moveAnimatorSet);
    pendingAnimatorSet.play(changeAnimatorSet).with(moveAnimatorSet);
    pendingAnimatorSet.play(addAnimatorSet).after(changeAnimatorSet);
    pendingAnimatorSet.play(addAnimatorSet).after(moveAnimatorSet);
    pendingAnimatorSet.start();
}
 
Example 14
Source File: PopupManager.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
public static void closePopup() {
	final RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container);
	int childCount = popupContainer.getChildCount();
	if (childCount > 0) {
		View background = null;
		View viewPopup = null;
		if (childCount == 1) {
			viewPopup = popupContainer.getChildAt(0);
		} else {
			background = popupContainer.getChildAt(0);
			viewPopup = popupContainer.getChildAt(1);
		}

		AnimatorSet animatorSet = new AnimatorSet();
		ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(viewPopup, "scaleX", 0f);
		ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(viewPopup, "scaleY", 0f);
		if (childCount > 1) {
			ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(background, "alpha", 0f);
			animatorSet.playTogether(scaleXAnimator, scaleYAnimator, alphaAnimator);
		} else {
			animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
		}
		animatorSet.setDuration(300);
		animatorSet.setInterpolator(new AccelerateInterpolator(2));
		animatorSet.addListener(new AnimatorListenerAdapter() {
			@Override
			public void onAnimationEnd(Animator animation) {
				popupContainer.removeAllViews();
			}
		});
		animatorSet.start();
	}
}
 
Example 15
Source File: ViewUtils.java    From fontster with Apache License 2.0 4 votes vote down vote up
public static void reveal(Activity activity, View view, View sourceView, int colorRes) {
  if (activity == null || view == null || sourceView == null) return;
  if (isLollipop()) {
    final ViewGroupOverlay groupOverlay =
        (ViewGroupOverlay) activity.getWindow().getDecorView().getOverlay();

    final Rect displayRect = new Rect();
    view.getGlobalVisibleRect(displayRect);

    // Make reveal cover the display and status bar.
    final View revealView = new View(activity);
    revealView.setTop(displayRect.top);
    revealView.setBottom(displayRect.bottom);
    revealView.setLeft(displayRect.left);
    revealView.setRight(displayRect.right);
    revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes));
    groupOverlay.add(revealView);

    final int[] clearLocation = new int[2];
    sourceView.getLocationInWindow(clearLocation);
    clearLocation[0] += sourceView.getWidth() / 2;
    clearLocation[1] += sourceView.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));

    try {
      final Animator revealAnimator =
          ViewAnimationUtils.createCircularReveal(revealView,
              revealCenterX, revealCenterY, 0.0f, revealRadius);
      revealAnimator.setDuration(
          activity.getResources().getInteger(android.R.integer.config_mediumAnimTime));

      final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
      alphaAnimator.setDuration(
          activity.getResources().getInteger(android.R.integer.config_shortAnimTime));
      alphaAnimator.addListener(new AnimatorListenerAdapter() {
        @Override public void onAnimationEnd(Animator animation) {
          super.onAnimationEnd(animation);
          view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in));
          view.setVisibility(View.VISIBLE);
        }
      });

      final AnimatorSet animatorSet = new AnimatorSet();
      animatorSet.play(revealAnimator).before(alphaAnimator);
      animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
      animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override public void onAnimationEnd(Animator animator) {
          groupOverlay.remove(revealView);
        }
      });

      animatorSet.start();
    } catch (IllegalStateException e) {
      Timber.i("View is detached - not animating");
    }
  } else {
    view.setVisibility(View.VISIBLE);
  }
}
 
Example 16
Source File: SlideOutUnderneathAnimation.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@Override
public void animate() {
	final ViewGroup parentView = (ViewGroup) view.getParent();
	final FrameLayout slideOutFrame = new FrameLayout(view.getContext());
	final int positionView = parentView.indexOfChild(view);
	slideOutFrame.setLayoutParams(view.getLayoutParams());
	slideOutFrame.setClipChildren(true);
	parentView.removeView(view);
	slideOutFrame.addView(view);
	parentView.addView(slideOutFrame, positionView);

	switch (direction) {
	case DIRECTION_LEFT:
		slideAnim = ObjectAnimator.ofFloat(view, View.TRANSLATION_X,
				view.getTranslationX() - view.getWidth());
		break;
	case DIRECTION_RIGHT:
		slideAnim = ObjectAnimator.ofFloat(view, View.TRANSLATION_X,
				view.getTranslationX() + view.getWidth());
		break;
	case DIRECTION_UP:
		slideAnim = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y,
				view.getTranslationY() - view.getHeight());
		break;
	case DIRECTION_DOWN:
		slideAnim = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y,
				view.getTranslationY() + view.getHeight());
		break;
	default:
		break;
	}

	AnimatorSet slideSet = new AnimatorSet();
	slideSet.play(slideAnim);
	slideSet.setInterpolator(interpolator);
	slideSet.setDuration(duration);
	slideSet.addListener(new AnimatorListenerAdapter() {

		@Override
		public void onAnimationEnd(Animator animation) {
			view.setVisibility(View.INVISIBLE);
			slideAnim.reverse();
			slideOutFrame.removeAllViews();
			parentView.removeView(slideOutFrame);
			parentView.addView(view, positionView);
			if (getListener() != null) {
				getListener().onAnimationEnd(
						SlideOutUnderneathAnimation.this);
			}
		}
	});
	slideSet.start();
}
 
Example 17
Source File: FeedItemAnimator.java    From InstaMaterial with Apache License 2.0 4 votes vote down vote up
private void animatePhotoLike(final FeedAdapter.CellFeedViewHolder holder) {
    holder.vBgLike.setVisibility(View.VISIBLE);
    holder.ivLike.setVisibility(View.VISIBLE);

    holder.vBgLike.setScaleY(0.1f);
    holder.vBgLike.setScaleX(0.1f);
    holder.vBgLike.setAlpha(1f);
    holder.ivLike.setScaleY(0.1f);
    holder.ivLike.setScaleX(0.1f);

    AnimatorSet animatorSet = new AnimatorSet();

    ObjectAnimator bgScaleYAnim = ObjectAnimator.ofFloat(holder.vBgLike, "scaleY", 0.1f, 1f);
    bgScaleYAnim.setDuration(200);
    bgScaleYAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator bgScaleXAnim = ObjectAnimator.ofFloat(holder.vBgLike, "scaleX", 0.1f, 1f);
    bgScaleXAnim.setDuration(200);
    bgScaleXAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator bgAlphaAnim = ObjectAnimator.ofFloat(holder.vBgLike, "alpha", 1f, 0f);
    bgAlphaAnim.setDuration(200);
    bgAlphaAnim.setStartDelay(150);
    bgAlphaAnim.setInterpolator(DECCELERATE_INTERPOLATOR);

    ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(holder.ivLike, "scaleY", 0.1f, 1f);
    imgScaleUpYAnim.setDuration(300);
    imgScaleUpYAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(holder.ivLike, "scaleX", 0.1f, 1f);
    imgScaleUpXAnim.setDuration(300);
    imgScaleUpXAnim.setInterpolator(DECCELERATE_INTERPOLATOR);

    ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(holder.ivLike, "scaleY", 1f, 0f);
    imgScaleDownYAnim.setDuration(300);
    imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR);
    ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(holder.ivLike, "scaleX", 1f, 0f);
    imgScaleDownXAnim.setDuration(300);
    imgScaleDownXAnim.setInterpolator(ACCELERATE_INTERPOLATOR);

    animatorSet.playTogether(bgScaleYAnim, bgScaleXAnim, bgAlphaAnim, imgScaleUpYAnim, imgScaleUpXAnim);
    animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpYAnim);

    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            likeAnimationsMap.remove(holder);
            resetLikeAnimationState(holder);
            dispatchChangeFinishedIfAllAnimationsEnded(holder);
        }
    });
    animatorSet.start();

    likeAnimationsMap.put(holder, animatorSet);
}
 
Example 18
Source File: ModeListView.java    From Camera2 with Apache License 2.0 4 votes vote down vote up
public void startFadeoutAnimation(Animator.AnimatorListener listener,
                                  final ModeSelectorItem selectedItem,
                                  int x, int y, final int modeId)
{
    mCoverPaint.setColor(0);
    mCoverPaint.setAlpha(0);

    mCircleDrawable.setIconDrawable(
            selectedItem.getIcon().getIconDrawableClone(),
            selectedItem.getIcon().getIconDrawableSize());
    mCircleDrawable.setCenter(new Point(x, y));
    mCircleDrawable.setColor(selectedItem.getHighlightColor());
    mCircleDrawable.setAnimatorListener(new AnimatorListenerAdapter()
    {
        @Override
        public void onAnimationEnd(Animator animation)
        {
            // Post mode selection runnable to the end of the message queue
            // so that current UI changes can finish before mode initialization
            // clogs up UI thread.
            post(new Runnable()
            {
                @Override
                public void run()
                {
                    // Select the focused item.
                    selectedItem.setSelected(true);
                    onModeSelected(modeId);
                }
            });
        }
    });

    // add fade out animator to a set, so we can freely add
    // the listener without having to worry about listener dupes
    AnimatorSet s = new AnimatorSet();
    s.play(mFadeOutAlphaAnimator);
    if (listener != null)
    {
        s.addListener(listener);
    }
    mCircleDrawable.animate();
    s.start();
}
 
Example 19
Source File: UndoView.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void hide(boolean apply, int animated) {
    if (getVisibility() != VISIBLE || !isShown) {
        return;
    }
    currentInfoObject = null;
    isShown = false;
    if (currentActionRunnable != null) {
        if (apply) {
            currentActionRunnable.run();
        }
        currentActionRunnable = null;
    }
    if (currentCancelRunnable != null) {
        if (!apply) {
            currentCancelRunnable.run();
        }
        currentCancelRunnable = null;
    }
    if (currentAction == ACTION_CLEAR || currentAction == ACTION_DELETE) {
        MessagesController.getInstance(currentAccount).removeDialogAction(currentDialogId, currentAction == ACTION_CLEAR, apply);
    }
    if (animated != 0) {
        AnimatorSet animatorSet = new AnimatorSet();
        if (animated == 1) {
            animatorSet.playTogether(ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, (fromTop ? -1.0f : 1.0f) * (AndroidUtilities.dp(8) + undoViewHeight)));
            animatorSet.setDuration(250);
        } else {
            animatorSet.playTogether(
                    ObjectAnimator.ofFloat(this, View.SCALE_X, 0.8f),
                    ObjectAnimator.ofFloat(this, View.SCALE_Y, 0.8f),
                    ObjectAnimator.ofFloat(this, View.ALPHA, 0.0f));
            animatorSet.setDuration(180);
        }
        animatorSet.setInterpolator(new DecelerateInterpolator());
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                setVisibility(INVISIBLE);
                setScaleX(1.0f);
                setScaleY(1.0f);
                setAlpha(1.0f);
            }
        });
        animatorSet.start();
    } else {
        setTranslationY((fromTop ? -1.0f : 1.0f) * (AndroidUtilities.dp(8) + undoViewHeight));
        setVisibility(INVISIBLE);
    }
}
 
Example 20
Source File: PasscodeView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void processDone(boolean fingerprint) {
    if (!fingerprint) {
        if (SharedConfig.passcodeRetryInMs > 0) {
            return;
        }
        String password = "";
        if (SharedConfig.passcodeType == 0) {
            password = passwordEditText2.getString();
        } else if (SharedConfig.passcodeType == 1) {
            password = passwordEditText.getText().toString();
        }
        if (password.length() == 0) {
            onPasscodeError();
            return;
        }
        if (!SharedConfig.checkPasscode(password)) {
            SharedConfig.increaseBadPasscodeTries();
            if (SharedConfig.passcodeRetryInMs > 0) {
                checkRetryTextView();
            }
            passwordEditText.setText("");
            passwordEditText2.eraseAllCharacters(true);
            onPasscodeError();
            return;
        }
    }
    SharedConfig.badPasscodeTries = 0;
    passwordEditText.clearFocus();
    AndroidUtilities.hideKeyboard(passwordEditText);

    AnimatorSet AnimatorSet = new AnimatorSet();
    AnimatorSet.setDuration(200);
    AnimatorSet.playTogether(
            ObjectAnimator.ofFloat(this, "translationY", AndroidUtilities.dp(20)),
            ObjectAnimator.ofFloat(this, "alpha", AndroidUtilities.dp(0.0f)));
    AnimatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            setVisibility(View.GONE);
        }
    });
    AnimatorSet.start();

    SharedConfig.appLocked = false;
    SharedConfig.saveConfig();
    NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetPasscode);
    setOnTouchListener(null);
    if (delegate != null) {
        delegate.didAcceptedPassword();
    }
}