android.animation.Animator Java Examples
The following examples show how to use
android.animation.Animator.
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 Project: Carbon Author: ZieIony File: AnimatorsCompat.java License: Apache License 2.0 | 6 votes |
public static void setAutoCancel(final ObjectAnimator animator) { animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { for (WeakReference<ObjectAnimator> wa : sRunningAnimators) { ObjectAnimator a = wa.get(); if (a == null) { continue; } if (hasSameTargetAndProperties(animator, a)) { a.cancel(); } } } }); }
Example #2
Source Project: MaterialMasterDetail Author: lurbas File: ContainersLayout.java License: Apache License 2.0 | 6 votes |
private void animateInFrameDetails() { frameDetails.setVisibility(View.VISIBLE); ViewUtils.onLaidOut(frameDetails, new Runnable() { @Override public void run() { ObjectAnimator alpha = ObjectAnimator.ofFloat(frameDetails, View.ALPHA, 0.4f, 1f); ObjectAnimator translate = ofFloat(frameDetails, View.TRANSLATION_Y, frameDetails.getHeight() * 0.3f, 0f); AnimatorSet set = new AnimatorSet(); set.playTogether(alpha, translate); set.setDuration(ANIM_DURATION); set.setInterpolator(new LinearOutSlowInInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); frameMaster.setVisibility(View.GONE); } }); set.start(); } }); }
Example #3
Source Project: mirror Author: zhihu File: MainActivity.java License: GNU General Public License v3.0 | 6 votes |
@Override public void onDragDismiss(final ArtboardView view, boolean isDragDown) { mIsDragDismiss = true; switchToArtboardListView(); view.animate().alpha(0.0F) .translationY(isDragDown ? -view.getHeight() : view.getHeight()) .setDuration(AnimUtils.DURATION) .setInterpolator(new AccelerateInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { mIsDragDismiss = false; mArtboardPagerView.getBackground().mutate().setAlpha(255); view.setTranslationY(0.0F); view.setAlpha(1.0F); } }) .start(); }
Example #4
Source Project: PlayLikeCurl Author: karankalsi File: AnimateCounter.java License: MIT License | 6 votes |
/** * Call to execute the animation */ public void execute(){ mValueAnimator = ValueAnimator.ofFloat(mStartValue, mEndValue); mValueAnimator.setDuration(mDuration); mValueAnimator.setInterpolator(mInterpolator); mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float current = Float.valueOf(valueAnimator.getAnimatedValue().toString()); if(mListener!=null)mListener.onValueUpdate(current); // mView.setText(String.format("%." + mPrecision + "f", current)); } }); mValueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mListener != null) { mListener.onAnimateCounterEnd(); } } }); mValueAnimator.start(); }
Example #5
Source Project: ShizuruNotes Author: MalitsPlus File: CalendarLayout.java License: Apache License 2.0 | 6 votes |
/** * 显示内容布局 */ @SuppressLint("NewApi") final void showContentView() { if (mContentView == null) return; mContentView.setTranslationY(getHeight() - mMonthView.getHeight()); mContentView.setVisibility(VISIBLE); mContentView.animate() .translationY(0) .setDuration(180) .setInterpolator(new LinearInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); } }); }
Example #6
Source Project: ChinaShare Author: maoruibin File: ShareView.java License: MIT License | 6 votes |
private void shareViewTranslationAnimator(final float start, final float end) { if (Build.VERSION.SDK_INT >= 11) { ObjectAnimator bottomAnim = ObjectAnimator.ofFloat(llContent, "translationY", start, end); bottomAnim.setDuration(duration); bottomAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (start < end) {//close ShareView shareView.setVisibility(View.GONE); } else {//show ShareView } } }); bottomAnim.start(); } }
Example #7
Source Project: natrium-android-wallet Author: BananoCoin File: BaseDialogFragment.java License: BSD 2-Clause "Simplified" License | 6 votes |
/** * Animate appearance of a view * * @param view View to animate * @param toVisibility Visibility at the end of animation * @param toAlpha Alpha at the end of animation * @param duration Animation duration in ms */ public static void animateView(final View view, final int toVisibility, float toAlpha, int duration) { boolean show = toVisibility == View.VISIBLE; if (show) { view.setAlpha(0); } view.setVisibility(View.VISIBLE); view.animate() .setDuration(duration) .alpha(show ? toAlpha : 0) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setVisibility(toVisibility); } }); }
Example #8
Source Project: Melophile Author: vpaliy File: PersonFragment.java License: Apache License 2.0 | 6 votes |
@Override public void hideLoading() { progress.animate() .scaleX(0) .scaleY(0) .setDuration(300) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); //if the animation is still running when the back button has been pressed if (progress != null) { progress.setVisibility(View.GONE); } } }).start(); }
Example #9
Source Project: ShimmerLayout Author: team-supercharge File: ShimmerLayout.java License: Apache License 2.0 | 6 votes |
public void startShimmerAnimation() { if (isAnimationStarted) { return; } if (getWidth() == 0) { startAnimationPreDrawListener = new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { getViewTreeObserver().removeOnPreDrawListener(this); startShimmerAnimation(); return true; } }; getViewTreeObserver().addOnPreDrawListener(startAnimationPreDrawListener); return; } Animator animator = getShimmerAnimation(); animator.start(); isAnimationStarted = true; }
Example #10
Source Project: SeeWeather Author: xcc3641 File: CircularAnimUtil.java License: Apache License 2.0 | 6 votes |
/** * 向四周伸张,直到完成显示。 */ @SuppressLint("NewApi") public static void show(View myView, float startRadius, long durationMills) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) { myView.setVisibility(View.VISIBLE); return; } int cx = (myView.getLeft() + myView.getRight()) / 2; int cy = (myView.getTop() + myView.getBottom()) / 2; int w = myView.getWidth(); int h = myView.getHeight(); // 勾股定理 & 进一法 int finalRadius = (int) Math.sqrt(w * w + h * h) + 1; Animator anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, startRadius, finalRadius); myView.setVisibility(View.VISIBLE); anim.setDuration(durationMills); anim.start(); }
Example #11
Source Project: edslite Author: sovworks File: CategoryPropertyEditor.java License: GNU General Public License v2.0 | 6 votes |
private void rotateIconAndChangeState() { IS_ANIMATING = true; _indicatorIcon.clearAnimation(); ObjectAnimator anim = ObjectAnimator.ofFloat(_indicatorIcon, View.ROTATION, _isExpanded ? 0 : 180); anim.setDuration(200); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) _indicatorIcon.setHasTransientState(true); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if(_isExpanded) collapse(); else expand(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) _indicatorIcon.setHasTransientState(false); IS_ANIMATING = false; } }); anim.start(); }
Example #12
Source Project: 365browser Author: mogoweb File: ToolbarPhone.java License: Apache License 2.0 | 6 votes |
private ObjectAnimator createExitTabSwitcherAnimation( final boolean animateNormalToolbar) { ObjectAnimator exitAnimation = ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 0.f); exitAnimation.setDuration(animateNormalToolbar ? TAB_SWITCHER_MODE_EXIT_NORMAL_ANIMATION_DURATION_MS : TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS); exitAnimation.setInterpolator(new LinearInterpolator()); exitAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { updateViewsForTabSwitcherMode(); } }); return exitAnimation; }
Example #13
Source Project: Android-Notification Author: lamydev File: NotificationView.java License: Apache License 2.0 | 6 votes |
/** * Rotate the contentView to x degree with animation. * * @param degree * @param alpha * @param listener * @param duration */ public void animateContentViewRotationX(float degree, float alpha, Animator.AnimatorListener listener, int duration) { if (DBG) Log.v(TAG, "animateContentViewRotationX - " + "degree=" + degree + ", alpha=" + alpha); mContentView.animate().cancel(); mContentView.animate() .alpha(alpha) .rotationX(degree) .setListener(listener) .setDuration(duration) .start(); }
Example #14
Source Project: droidkaigi2016 Author: konifar File: MapSearchView.java License: Apache License 2.0 | 6 votes |
private void revealOn() { if (binding.mapListContainer.getVisibility() == VISIBLE) return; View container = binding.mapListContainer; Animator animator = ViewAnimationUtils.createCircularReveal( container, getRevealCenterX(container), container.getTop(), 0, (float) Math.hypot(container.getWidth(), container.getHeight())); animator.setInterpolator(INTERPOLATOR); animator.setDuration(getResources().getInteger(R.integer.view_reveal_mills)); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { binding.mapListContainer.setVisibility(VISIBLE); if (onVisibilityChangeListener != null) { onVisibilityChangeListener.onChange(); } } }); animator.start(); }
Example #15
Source Project: 365browser Author: mogoweb File: EmptyBackgroundViewTablet.java License: Apache License 2.0 | 6 votes |
public void setEmptyContainerState(boolean shouldShow) { Animator nextAnimator = null; if (shouldShow && getVisibility() != View.VISIBLE && mCurrentTransitionAnimation != mAnimateInAnimation) { nextAnimator = mAnimateInAnimation; UiUtils.hideKeyboard(this); } else if (!shouldShow && getVisibility() != View.GONE && mCurrentTransitionAnimation != mAnimateOutAnimation) { nextAnimator = mAnimateOutAnimation; } if (nextAnimator != null) { if (mCurrentTransitionAnimation != null) mCurrentTransitionAnimation.cancel(); mCurrentTransitionAnimation = nextAnimator; mCurrentTransitionAnimation.start(); } }
Example #16
Source Project: EhViewer Author: seven332 File: ViewAnimationUtils.java License: Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static Animator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { if (API_SUPPORT_CIRCULAR_REVEAL) { return android.view.ViewAnimationUtils.createCircularReveal( view, centerX, centerY, startRadius, endRadius); } else if (view instanceof Reveal){ return createRevealAnimator((Reveal) view, centerX, centerY, startRadius, endRadius); } else { throw new IllegalStateException("Only View implements CircularReveal or" + " api >= 21 can create circular reveal"); } }
Example #17
Source Project: Genius-Android Author: qiujuer File: BalloonMarker.java License: Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public void animateClose() { mBalloonMarkerDrawable.stop(); ViewPropertyAnimator animator = mNumber.animate(); animator.alpha(0f); animator.setDuration(100); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { animator.withEndAction(new Runnable() { @Override public void run() { //We use INVISIBLE instead of GONE to avoid a requestLayout mNumber.setVisibility(View.INVISIBLE); mBalloonMarkerDrawable.animateToNormal(); } }); } else { animator.setListener(new AnimatorListener() { @Override public void onAnimationEnd(Animator animation) { //We use INVISIBLE instead of GONE to avoid a requestLayout mNumber.setVisibility(View.INVISIBLE); mBalloonMarkerDrawable.animateToNormal(); } }); } animator.start(); }
Example #18
Source Project: Carbon Author: ZieIony File: RecyclerView.java License: Apache License 2.0 | 5 votes |
public void setOutAnimator(Animator outAnim) { if (this.outAnim != null) this.outAnim.setTarget(null); this.outAnim = outAnim; if (outAnim != null) outAnim.setTarget(this); }
Example #19
Source Project: Telegram Author: DrKLO File: MediaActivity.java License: GNU General Public License v2.0 | 5 votes |
private boolean onItemLongClick(MessageObject item, View view, int a) { if (actionBar.isActionModeShowed() || getParentActivity() == null) { return false; } AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus()); selectedFiles[item.getDialogId() == dialog_id ? 0 : 1].put(item.getId(), item); if (!item.canDeleteMessage(false, null)) { cantDeleteMessagesCount++; } actionBar.createActionMode().getItem(delete).setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE); if (gotoItem != null) { gotoItem.setVisibility(View.VISIBLE); } selectedMessagesCountTextView.setNumber(1, false); AnimatorSet animatorSet = new AnimatorSet(); ArrayList<Animator> animators = new ArrayList<>(); for (int i = 0; i < actionModeViews.size(); i++) { View view2 = actionModeViews.get(i); AndroidUtilities.clearDrawableAnimation(view2); animators.add(ObjectAnimator.ofFloat(view2, View.SCALE_Y, 0.1f, 1.0f)); } animatorSet.playTogether(animators); animatorSet.setDuration(250); animatorSet.start(); scrolling = false; if (view instanceof SharedDocumentCell) { ((SharedDocumentCell) view).setChecked(true, true); } else if (view instanceof SharedPhotoVideoCell) { ((SharedPhotoVideoCell) view).setChecked(a, true, true); } else if (view instanceof SharedLinkCell) { ((SharedLinkCell) view).setChecked(true, true); } else if (view instanceof SharedAudioCell) { ((SharedAudioCell) view).setChecked(true, true); } if (!actionBar.isActionModeShowed()) { actionBar.showActionMode(null, actionModeBackground, null, null, null, 0); resetScroll(); } return true; }
Example #20
Source Project: android-topeka Author: googlearchive File: TextResizeTransition.java License: Apache License 2.0 | 5 votes |
@Override public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { if (startValues == null || endValues == null) { return null; } float initialTextSize = (float) startValues.values.get(PROPERTY_NAME_TEXT_RESIZE); float targetTextSize = (float) endValues.values.get(PROPERTY_NAME_TEXT_RESIZE); TextView targetView = (TextView) endValues.view; targetView.setTextSize(TypedValue.COMPLEX_UNIT_PX, initialTextSize); int initialPaddingStart = (int) startValues.values.get(PROPERTY_NAME_PADDING_RESIZE); int targetPaddingStart = (int) endValues.values.get(PROPERTY_NAME_PADDING_RESIZE); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(targetView, ViewUtils.PROPERTY_TEXT_SIZE, initialTextSize, targetTextSize), ObjectAnimator.ofInt(targetView, ViewUtils.PROPERTY_TEXT_PADDING_START, initialPaddingStart, targetPaddingStart)); return animatorSet; }
Example #21
Source Project: AchievementView Author: RafaelBarbosatec File: FunctionsUtil.java License: Apache License 2.0 | 5 votes |
public static void applyAlpha(View view, long delay, float alpha, Animator.AnimatorListener animatorListener){ ViewPropertyAnimator animator2 = view.animate(); animator2.alpha(alpha); animator2.setInterpolator(new DecelerateInterpolator()); animator2.setStartDelay(delay); animator2.setListener(animatorListener); animator2.start(); }
Example #22
Source Project: ClipPathLayout Author: dqh147258 File: TransitionFragmentContainer.java License: Apache License 2.0 | 5 votes |
private void removeViewInternal(final View child) { if (child.getVisibility() != VISIBLE) { super.removeView(child); return; } executeRemoveViewTask(); View current = findNextTopView(child); if (current == null) { mRemoveViewReference = new WeakReference<View>(child); sendRemoveViewMessage(); return; } final TransitionAdapter adapter = switchView(current, true); if (mHandler.hasMessages(MESSAGE_REMOVE_VIEW)) { mHandler.removeMessages(MESSAGE_REMOVE_VIEW); } mRemoveViewReference = new WeakReference<View>(child); mValueAnimator = adapter.getAnimator(); mValueAnimator.setInterpolator(new DecelerateInterpolator()); mValueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { sendRemoveViewMessage(); } }); startAnimator(); return; }
Example #23
Source Project: Telegram Author: DrKLO File: ChatListItemAnimator.java License: GNU General Public License v2.0 | 5 votes |
protected boolean endChangeAnimationIfNecessary(ChangeInfo changeInfo, RecyclerView.ViewHolder item) { if (BuildVars.LOGS_ENABLED) { FileLog.d("end change if necessary"); } Animator a = animators.remove(item); if (a != null) { a.cancel(); } boolean oldItem = false; if (changeInfo.newHolder == item) { changeInfo.newHolder = null; } else if (changeInfo.oldHolder == item) { changeInfo.oldHolder = null; oldItem = true; } else { return false; } item.itemView.setAlpha(1); if (item.itemView instanceof ChatMessageCell) { ((ChatMessageCell) item.itemView).setAnimationOffsetX(0); ((ChatMessageCell) item.itemView).getTransitionParams().resetAnimation(); } else { item.itemView.setTranslationX(0); } item.itemView.setTranslationY(0); dispatchChangeFinished(item, oldItem); return true; }
Example #24
Source Project: Flubber Author: Appolica File: FABRevealProvider.java License: Apache License 2.0 | 5 votes |
@Override public Animator createAnimationFor(AnimationBody animationBody, final View view) { final AnimatorSet animatorSet = new AnimatorSet(); final Animator animationClose = getCloseReveal(view); final Animator animationOpen = getOpenReveal(view); animationClose.addListener( SimpleAnimatorListener.forEnd(animation -> ((FloatingActionButton) view).setImageResource(newIconResId))); animatorSet.play(animationOpen).after(animationClose); return animatorSet; }
Example #25
Source Project: Camera2 Author: Yuloran File: ModeListView.java License: Apache License 2.0 | 5 votes |
@Override public void startAnimation(Animator.AnimatorListener listener) { if (mPeepHoleAnimator != null && mPeepHoleAnimator.isRunning()) { return; } if (mPeepHoleCenterY == UNSET || mPeepHoleCenterX == UNSET) { mPeepHoleCenterX = mWidth / 2; mPeepHoleCenterY = mHeight / 2; } mCirclePaint.setAlpha(255); mCoverPaint.setAlpha(255); // add peephole and reveal animators to a set, so we can // freely add the listener without having to worry about // listener dupes AnimatorSet s = new AnimatorSet(); s.play(mPeepHoleAnimator).with(mRevealAlphaAnimator); if (listener != null) { s.addListener(listener); } s.start(); }
Example #26
Source Project: delion Author: derry File: SwipableOverlayView.java License: Apache License 2.0 | 5 votes |
/** * Creates an AnimatorListenerAdapter that cleans up after an animation is completed. * @return {@link AnimatorListenerAdapter} to use for animations. */ private AnimatorListener createAnimatorListener() { return new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mGestureState = GESTURE_NONE; mCurrentAnimation = null; mIsBeingDisplayedForFirstTime = false; } }; }
Example #27
Source Project: PersistentSearchView Author: crysehillmes File: SupportAnimatorLollipop.java License: Apache License 2.0 | 5 votes |
@Override public void setInterpolator(Interpolator value) { Animator a = mAnimator.get(); if(a != null) { a.setInterpolator(value); } }
Example #28
Source Project: WeGit Author: Leaking File: SupportAnimatorLollipop.java License: Apache License 2.0 | 5 votes |
@Override public void setInterpolator(Interpolator value) { Animator a = mNativeAnimator.get(); if(a != null) { a.setInterpolator(value); } }
Example #29
Source Project: TurboLauncher Author: Phonemetra File: LauncherAnimUtils.java License: Apache License 2.0 | 5 votes |
public static void onDestroyActivity() { HashSet<Animator> animators = new HashSet<Animator>(sAnimators.keySet()); for (Animator a : animators) { if (a.isRunning()) { a.cancel(); } sAnimators.remove(a); } }
Example #30
Source Project: tilt-game-android Author: mediamonks File: WorldController.java License: MIT License | 5 votes |
public void playLevelEndAnimation() { Vector2 destPos = _gameLevel.getSinkholeLocation(); // if level doesn't have a sink, don't bother with the animation if (_ballSprite == null || destPos == null) { _gameLevelStateListener.onOutAnimationComplete(); return; } _isAnimating = true; long duration = 200; ObjectAnimator.ofFloat(_ballSprite, "x", destPos.x).setDuration(duration).start(); ObjectAnimator animator = ObjectAnimator.ofFloat(_ballSprite, "y", destPos.y).setDuration(duration); animator.start(); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { _ballSprite.hide(100); _sinkHole.hide(200, null); _sinkHoleBorder.hide(300, new AnimationCallback() { @Override public void onComplete() { if (_gameLevelStateListener != null) { _gameLevelStateListener.onOutAnimationComplete(); } _isAnimating = false; } }); } }); }