public void openDrawer(boolean fast) { if (!allowOpenDrawer) { return; } if (AndroidUtilities.isTablet() && parentActionBarLayout != null && parentActionBarLayout.parentActivity != null) { AndroidUtilities.hideKeyboard(parentActionBarLayout.parentActivity.getCurrentFocus()); } cancelCurrentAnimation(); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(this, "drawerPosition", drawerLayout.getMeasuredWidth())); animatorSet.setInterpolator(new DecelerateInterpolator()); if (fast) { animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * (drawerLayout.getMeasuredWidth() - drawerPosition)), 50)); } else { animatorSet.setDuration(300); } animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animator) { onDrawerAnimationEnd(true); } }); animatorSet.start(); currentAnimation = animatorSet; }
/** * @param view View to be animated * @param borderWidth The width of the spinning bar * @param arcColor The color of the spinning bar */ public CircularAnimatedDrawable(View view, float borderWidth, int arcColor, @DrawableRes int innerResource, @ColorInt int innerResourceColorFilter) { mAnimatedView = view; mBorderWidth = borderWidth; if (innerResource != 0) { setInnerResource(innerResource); setInnerResourceColorFilter(innerResourceColorFilter); } mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(borderWidth); mPaint.setColor(arcColor); setupAnimations(); shouldDraw = true; mAnimatorSet = new AnimatorSet(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); user = (ClearEditText) findViewById(R.id.user); user.addTextChangedListener(userTextWatcher); user.setOnFocusChangeListener(this); pass = (ClearEditText) findViewById(R.id.pass); pass.setOnFocusChangeListener(this); pass.addTextChangedListener(passTextWatcher); login = (Button) findViewById(R.id.login); login.setOnClickListener(this); register = (Button) findViewById(R.id.register); register.setOnClickListener(this); forget = (TextView) findViewById(R.id.forget); ObjectAnimator animator = ObjectAnimator.ofFloat(forget, "rotation", 0, 360f); ObjectAnimator animator1 = ObjectAnimator.ofFloat(forget, "alpha", 1f, 0f, 1f); AnimatorSet set = new AnimatorSet(); set.play(animator).with(animator1); set.setDuration(5000); set.start(); }
@Override public void prepareStateChange(State toState, AnimatorSet targetAnim) { int finalAlpha = getAlphaForState(toState); if (targetAnim == null) { mBgPaint.setAlpha(finalAlpha); invalidate(); } else { ObjectAnimator anim = ObjectAnimator.ofArgb(mBgPaint, "alpha", finalAlpha); anim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { invalidate(); } }); targetAnim.play(anim); } }
public Animator createDismissAnimator(final View target) { if (mHasCustomAnimationParams) { final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat( target, View.SCALE_X, mDismissEndXScale); final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat( target, View.SCALE_Y, mDismissEndYScale); final AnimatorSet dismissAnimator = new AnimatorSet(); dismissAnimator.play(scaleXAnimator).with(scaleYAnimator); final int dismissDuration = Math.min(mDismissDuration, mLingerTimeout); dismissAnimator.setDuration(dismissDuration); dismissAnimator.setInterpolator(ACCELERATE_INTERPOLATOR); return dismissAnimator; } final Animator animator = AnimatorInflater.loadAnimator( target.getContext(), mDismissAnimatorResId); animator.setTarget(target); animator.setInterpolator(ACCELERATE_INTERPOLATOR); return animator; }
@Override protected void prepare(AnimatorSet animatorSet, View target) { ViewGroup parent = (ViewGroup) target.getParent(); int distance = parent.getHeight() - target.getTop(); animatorSet.playTogether( ObjectAnimator.ofFloat(target, "alpha", 0, 1), ObjectAnimator.ofFloat(target, "translationY", distance, 0) ); }
private void hideRecordedAudioPanel() { audioToSendPath = null; audioToSend = null; audioToSendMessageObject = null; AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.playTogether( ObjectAnimator.ofFloat(recordedAudioPanel, "alpha", 0.0f) ); AnimatorSet.setDuration(200); AnimatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { recordedAudioPanel.setVisibility(GONE); } }); AnimatorSet.start(); }
public AnimatorSet getAnimationToState(Workspace.State fromState, Workspace.State toState, boolean animated, HashMap<View, Integer> layerViews) { AccessibilityManager am = (AccessibilityManager) mLauncher.getSystemService(Context.ACCESSIBILITY_SERVICE); final boolean accessibilityEnabled = am.isEnabled(); TransitionStates states = new TransitionStates(fromState, toState); int workspaceDuration = getAnimationDuration(states); animateWorkspace(states, animated, workspaceDuration, layerViews, accessibilityEnabled); animateBackgroundGradient(states, animated, BACKGROUND_FADE_OUT_DURATION); return mStateAnimator; }
public static void animateSunblind(RecyclerView.ViewHolder holder, boolean goesDown) { int holderHeight = holder.itemView.getHeight(); holder.itemView.setPivotY(goesDown == true ? 0 : holderHeight); holder.itemView.setPivotX(holder.itemView.getHeight()); AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator animatorTranslateY = ObjectAnimator.ofFloat(holder.itemView, "translationY", goesDown == true ? 300 : -300, 0); ObjectAnimator animatorRotation = ObjectAnimator.ofFloat(holder.itemView, "rotationX", goesDown == true ? -90f : 90, 0f); ObjectAnimator animatorScaleX = ObjectAnimator.ofFloat(holder.itemView, "scaleX", 0.5f, 1f); animatorSet.playTogether(animatorTranslateY, animatorRotation, animatorScaleX); animatorSet.setInterpolator(new DecelerateInterpolator(1.1f)); animatorSet.setDuration(1000); animatorSet.start(); }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues); if (startValues == null || endValues == null || changeBounds == null) { return null; } Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR); Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS); Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR); Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS); if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) { return null; } MorphDrawable background = new MorphDrawable(startColor, startCornerRadius); endValues.view.setBackground(background); Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor); Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius); // hide child views (offset down & fade out) if (endValues.view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) endValues.view; for (int i = 0; i < vg.getChildCount(); i++) { View v = vg.getChildAt(i); v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L) .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_linear_in)) .start(); } } AnimatorSet transition = new AnimatorSet(); transition.playTogether(changeBounds, corners, color); transition.setInterpolator(AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in)); transition.setDuration(300); return transition; }
private void startAnimation() { float sunYStart = mSunView.getTop(); float sunYEnd = mSkyView.getHeight(); ObjectAnimator heightAnimator = ObjectAnimator .ofFloat(mSunView, "y", sunYStart, sunYEnd) .setDuration(3000); heightAnimator.setInterpolator(new AccelerateInterpolator()); ObjectAnimator sunsetSkyAnimator = ObjectAnimator .ofInt(mSkyView, "backgroundColor", mBlueSkyColor, mSunsetSkyColor) .setDuration(3000); sunsetSkyAnimator.setEvaluator(new ArgbEvaluator()); ObjectAnimator nightSkyAnimator = ObjectAnimator .ofInt(mSkyView, "backgroundColor", mSunsetSkyColor, mNightSkyColor) .setDuration(1500); nightSkyAnimator.setEvaluator(new ArgbEvaluator()); AnimatorSet animatorSet = new AnimatorSet(); animatorSet .play(heightAnimator) .with(sunsetSkyAnimator) .before(nightSkyAnimator); animatorSet.start(); }
@Override public Animator createOpenAnimation(boolean isContainerAboveIcon, boolean pivotLeft) { AnimatorSet openAnimation = LauncherAnimUtils.createAnimatorSet(); openAnimation.play(super.createOpenAnimation(isContainerAboveIcon, pivotLeft)); for (int i = 0; i < mShortcutsLayout.getChildCount(); i++) { if (!(mShortcutsLayout.getChildAt(i) instanceof DeepShortcutView)) { continue; } DeepShortcutView shortcutView = ((DeepShortcutView) mShortcutsLayout.getChildAt(i)); View deepShortcutIcon = shortcutView.getIconView(); deepShortcutIcon.setScaleX(0); deepShortcutIcon.setScaleY(0); openAnimation.play(LauncherAnimUtils.ofPropertyValuesHolder( deepShortcutIcon, new PropertyListBuilder().scale(1).build())); } return openAnimation; }
@Override public Animator createCloseAnimation(boolean isContainerAboveIcon, boolean pivotLeft, long duration) { AnimatorSet closeAnimation = LauncherAnimUtils.createAnimatorSet(); closeAnimation.play(super.createCloseAnimation(isContainerAboveIcon, pivotLeft, duration)); for (int i = 0; i < mShortcutsLayout.getChildCount(); i++) { if (!(mShortcutsLayout.getChildAt(i) instanceof DeepShortcutView)) { continue; } DeepShortcutView shortcutView = ((DeepShortcutView) mShortcutsLayout.getChildAt(i)); View deepShortcutIcon = shortcutView.getIconView(); deepShortcutIcon.setScaleX(1); deepShortcutIcon.setScaleY(1); closeAnimation.play(LauncherAnimUtils.ofPropertyValuesHolder( deepShortcutIcon, new PropertyListBuilder().scale(0).build())); } return closeAnimation; }
@Override protected void prepare(AnimatorSet animatorSet, View target) { animatorSet.playTogether( ObjectAnimator.ofFloat(target, "scaleX", 0.45f, 1), ObjectAnimator.ofFloat(target, "scaleY", 0.45f, 1), ObjectAnimator.ofFloat(target, "alpha", 0, 1) ); }
/** * Function to hide tool bar */ public void hideToolbar() { ObjectAnimator toolbarAnimY = ObjectAnimator.ofFloat(myToolbarContainer, "y", -(myToolbarContainer.getHeight())); AnimatorSet toolbarHideAnimation = new AnimatorSet(); toolbarHideAnimation.setInterpolator(new LinearInterpolator()); toolbarHideAnimation.play(toolbarAnimY); toolbarHideAnimation.start(); }
private void shakeTextView(final float x, final int num) { if (num == 6) { return; } AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.playTogether(ObjectAnimator.ofFloat(passcodeTextView, "translationX", AndroidUtilities.dp(x))); AnimatorSet.setDuration(50); AnimatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { shakeTextView(num == 5 ? 0 : -x, num + 1); } }); AnimatorSet.start(); }
protected Animator getAddAnimator(View view, int top, int position, int addOccurTop, int addOccurPosition) { view.setAlpha(0); view.clearAnimation(); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(alphaObjectAnimator(view, true, 50, false)); if (addOccurTop != top) { animatorSet.play(getOffsetAnimator(view, addOccurTop, top)); } animatorSet.setStartDelay((long) (view.getHeight() * mOffsetDurationUnit)); return animatorSet; }
private void doPreLayoutAnimation(Animator.AnimatorListener listener) { final AnimatorSet animatorSet = new AnimatorSet(); ArrayList<Long> deleteIds = new ArrayList<>(); int i; for (i = 0; i < mTopMap.size(); i++) { long id = mTopMap.keyAt(i); int newPos = getPositionForId(id); if (newPos < 0) { // delete int oldPos = mPositionMap.get(id); View child = getChildAt(oldPos); final Animator anim = getDeleteAnimator(child); mPositionMap.remove(id); animatorSet.play(anim); deleteIds.add(id); } } for (i = 0; i < deleteIds.size(); i++) { mTopMap.remove(deleteIds.get(i)); } if (mOpenChangeDisappearAnimation) { for (i = 0; i < mPositionMap.size(); i++) { View view = getChildAt(mPositionMap.valueAt(i)); ViewCompat.setHasTransientState(view, true); mDetachViewsMap.put(mPositionMap.keyAt(i), view); } } if (!animatorSet.getChildAnimations().isEmpty()) { animatorSet.addListener(listener); animatorSet.start(); } else { listener.onAnimationEnd(animatorSet); } }
private void doStart(long delay) { ObjectAnimator topMaskAnimator = ObjectAnimator.ofFloat(topMaskView, "translationY", topMaskView.getTranslationY(), -halfHitBlockHeight); ObjectAnimator bottomMaskAnimator = ObjectAnimator.ofFloat(bottomMaskView, "translationY", bottomMaskView.getTranslationY(), halfHitBlockHeight); ObjectAnimator maskShadowAnimator = ObjectAnimator.ofFloat(maskReLayout, "alpha", maskReLayout.getAlpha(), 0); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(topMaskAnimator).with(bottomMaskAnimator).with(maskShadowAnimator); animatorSet.setDuration(800); animatorSet.setStartDelay(delay); animatorSet.start(); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { topMaskView.setVisibility(View.GONE); bottomMaskView.setVisibility(View.GONE); maskReLayout.setVisibility(View.GONE); onGameStart(); } }); }
/** * @param animator1 * @param animator2 * @param animator3 * @param animator4 * @param animator5 * @return 按顺序播放动画 */ public static AnimatorSet startAnimation(ObjectAnimator animator1, ObjectAnimator animator2, ObjectAnimator animator3, ObjectAnimator animator4, ObjectAnimator animator5) { AnimatorSet animSet = new AnimatorSet(); // animSet.playSequentially(animators); animSet.play(animator1).before(animator2); animSet.play(animator3).after(animator2); animSet.play(animator4).after(animator3); animSet.play(animator5).after(animator4); animSet.start(); return animSet; }
@Override public void fireAnimation() { float offsetX=parent.getWidth()-(parent.getWidth()-first.getLeft()+getResources().getDimension(R.dimen.option_size)); ObjectAnimator firstAnimator=ObjectAnimator.ofFloat(first,View.TRANSLATION_X,0); ObjectAnimator secondAnimator=ObjectAnimator.ofFloat(second,View.TRANSLATION_X,0); ObjectAnimator lastAnimator=ObjectAnimator.ofFloat(last,View.TRANSLATION_X,0); ObjectAnimator buttonAnimator=ObjectAnimator.ofFloat(controller,View.TRANSLATION_X,controller.getTranslationX()); first.setTranslationX(-offsetX); second.setTranslationX(-offsetX); last.setTranslationX(-offsetX); controller.setTranslationX(-controller.getWidth()); buttonAnimator.setInterpolator(new BounceOvershootInterpolator(4)); AnimatorSet buttonSet=new AnimatorSet(); buttonSet.playTogether(firstAnimator,secondAnimator,lastAnimator); buttonSet.setInterpolator(new BounceOvershootInterpolator(2)); AnimatorSet animatorSet=new AnimatorSet(); animatorSet.setStartDelay(500); animatorSet.playTogether(buttonSet,buttonAnimator); animatorSet.start(); }
@Override protected void focusOut(View v,int pos) { ObjectAnimator scaleX = ObjectAnimator.ofFloat(v, "scaleX", 1.05f, 1.0f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(v, "scaleY", 1.05f, 1.0f); AnimatorSet set = new AnimatorSet(); set.play(scaleX).with(scaleY); set.start(); }
private void toggleCheckImageView(boolean show) { AnimatorSet animatorSet = new AnimatorSet(); ArrayList<Animator> arrayList = new ArrayList<>(); arrayList.add(ObjectAnimator.ofFloat(pickerView, "alpha", show ? 1.0f : 0.0f)); if (needCaptionLayout) { arrayList.add(ObjectAnimator.ofFloat(captionTextView, "alpha", show ? 1.0f : 0.0f)); } if (sendPhotoType == 0) { arrayList.add(ObjectAnimator.ofFloat(checkImageView, "alpha", show ? 1.0f : 0.0f)); } animatorSet.playTogether(arrayList); animatorSet.setDuration(200); animatorSet.start(); }
private void runRevealNProgress(){ revealAnimator.setDuration(duration(R.integer.conceal_duration)); revealAnimator.setInterpolator(new DecelerateInterpolator()); seekBar.setProgress(80); ObjectAnimator progressAnimator=ObjectAnimator.ofInt(seekBar,"progress",80,20); ObjectAnimator scaleY=ObjectAnimator.ofFloat(seekBar,View.SCALE_Y,0,1f); progressAnimator.setInterpolator(new DecelerateInterpolator()); progressAnimator.setDuration(duration(R.integer.progress_duration)); scaleY.setDuration(duration(R.integer.progress_duration)); AnimatorSet animatorSet=new AnimatorSet(); animatorSet.play(revealAnimator); animatorSet.play(progressAnimator).with(scaleY); animatorSet.start(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SPUtils sp=new SPUtils("theme_id"); int theme_id = sp.getInt("theme_id", R.style.AppTheme); setTheme(theme_id); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //透明状态栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); //透明导航栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); } setContentView(R.layout.activity_solash); ButterKnife.bind(this); set = new AnimatorSet(); ObjectAnimator translationX = ObjectAnimator.ofFloat(ivSplash, "translationX", 600, 0); ObjectAnimator translationY = ObjectAnimator .ofFloat(ivSplash, "translationY", -100, 90, -80, 70, -60, 50); set.playTogether(translationX, translationY); set.setDuration(2000); addListener(); }
private void startChildAnimation(View child) { if (animationEnabled) { AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(child, "alpha", 0.0f, 1.0f), ObjectAnimator.ofFloat(child, "translationY", AndroidUtilities.dp(showedFromBotton ? 6 : -6), 0)); animatorSet.setDuration(180); animatorSet.setInterpolator(decelerateInterpolator); animatorSet.start(); } }
private void showTitleAndMenu(Point globalOffset) { linearLayout_contains.setVisibility(View.GONE); toolbar.setTitle(userHasSigned.getUser_name()); toolbar.setSubtitle("注册时间:" + userHasSigned.getCreated_at()); toolbar.setAlpha(1.0f); Rect finnal_toobar = new Rect(); Rect finnal_liner_bottom = new Rect(); toolbar.getGlobalVisibleRect(finnal_toobar); linearLayout_bottom.getGlobalVisibleRect(finnal_liner_bottom); Log.i(TAG, "showTitleAndMenu: " + finnal_liner_bottom.toString() + finnal_toobar.toString()); finnal_toobar.offset(-globalOffset.x, -globalOffset.y); finnal_liner_bottom.offset(-globalOffset.x, -globalOffset.y); Log.i(TAG, "showTitleAndMenu: " + finnal_liner_bottom.toString() + finnal_toobar.toString()); linearLayout_bottom.setAlpha(1.0f); AnimatorSet set1 = new AnimatorSet(); set1.play(ObjectAnimator.ofFloat(toolbar, View.Y, -finnal_toobar.height(), 0.0f)) //(1280+finnal_liner_bottom.top)/2 .with(ObjectAnimator.ofFloat(linearLayout_bottom, View.Y, finnal_liner_bottom.bottom, finnal_liner_bottom.top)); set1.setDuration(400); set1.start(); }
public eqlizerMain(Context context, int width, int height) { super(context, width, height); setBackgroundColor(mainBackground.Color0); setPivotY(height*0.7f); setPivotX(width*0.5f); Ui.ef.clickPlay(); setAlpha(0); Set = new AnimatorSet(); Set.setInterpolator(Ui.cd.TH); Set.setDuration(200); Set.playTogether( ObjectAnimator.ofFloat(this, "Y",height * 0.5f, 0), ObjectAnimator.ofFloat(this, "Alpha", 1.0F) ); Set.start(); init(); }
private void checkEnhance() { if (enhanceValue == 0) { AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.setDuration(200); AnimatorSet.playTogether(ObjectAnimator.ofInt(valueSeekBar, "progress", 50)); AnimatorSet.start(); } }
@Override public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues); if (startValues == null || endValues == null || changeBounds == null) { return null; } Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR); Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS); Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR); Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS); if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) { return null; } MorphDrawable background = new MorphDrawable(startColor, startCornerRadius); endValues.view.setBackground(background); Animator color = ObjectAnimator.ofArgb(background, MorphDrawable.COLOR, endColor); Animator corners = ObjectAnimator.ofFloat(background, MorphDrawable.CORNER_RADIUS, endCornerRadius); // hide child views (offset down & fade out) if (endValues.view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) endValues.view; for (int i = 0; i < vg.getChildCount(); i++) { View v = vg.getChildAt(i); v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L) .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_linear_in)) .start(); } } AnimatorSet transition = new AnimatorSet(); transition.playTogether(changeBounds, corners, color); transition.setInterpolator(AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in)); transition.setDuration(300); return transition; }
/** * Sets the current workspace {@link State}, returning an animation transitioning the workspace * to that new state. */ public Animator setStateWithAnimation(State toState, boolean animated, HashMap<View, Integer> layerViews) { // Create the animation to the new state AnimatorSet workspaceAnim = mStateTransitionAnimation.getAnimationToState(mState, toState, animated, layerViews); boolean shouldNotifyWidgetChange = !mState.shouldUpdateWidget && toState.shouldUpdateWidget; // Update the current state mState = toState; updateAccessibilityFlags(); if (shouldNotifyWidgetChange) { mLauncher.notifyWidgetProvidersChanged(); } if (mOnStateChangeListener != null) { mOnStateChangeListener.prepareStateChange(toState, animated ? workspaceAnim : null); } return workspaceAnim; }
/** * 对 bitmap 进行伪 3d 变换 * * @param child * @param position * @param offset */ private void makeChildTransfromer(View child, int position, float offset) { child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight()); float scale = 0; float scaleX = 0; scale = 1 - Math.abs(offset) * 0.25f; scaleX = 1 - Math.abs(offset) * 0.15f; // 延x轴移动的距离应该根据center图片决定 float translateY = 0; final int originalChildHeight = (int) (mChildHeight - mChildHeight * reflectHeightFraction - reflectGap); final float originalChildHeightScale = (float) originalChildHeight / child.getHeight(); final float childHeightScale = originalChildHeightScale * scale; final float childWidthScale = originalChildHeightScale * scaleX; final int centerChildHeight = (int) (child.getHeight() * originalChildHeightScale); topSpace = (mHeight-centerChildHeight)/2; // float baseDis = dip2px(getContext(),24); baseDis = centerChildHeight/4.9f; translateY = (mHeight-centerChildHeight)/2- baseDis *offset*-1; //根据offset 算出透明度 float alpha = 254 - Math.abs(offset) * STANDARD_ALPHA; child.setAlpha(0); if (alpha < 0) { alpha = 0; } else if (alpha > 254) { alpha = 254; } child.setAlpha(alpha / 254.0f); ObjectAnimator anim1 = ObjectAnimator.ofFloat(child, "scaleX", 1.0f, childWidthScale); ObjectAnimator anim2 = ObjectAnimator.ofFloat(child, "scaleY", 1.0f, childHeightScale); AnimatorSet animSet = new AnimatorSet(); animSet.setDuration(0); //两个动画同时执行 animSet.playTogether(anim1, anim2); child.setPivotX(child.getWidth()/2); child.setPivotY(child.getHeight() / 2); //显示的调用invalidate child.invalidate(); animSet.setTarget(child); animSet.start(); child.setTranslationX(mChildTranslateX); child.setTranslationY(translateY); }
private void runMenuItemEnterAnimations() { mMenuItemEnterAnimator = new AnimatorSet(); AnimatorSet.Builder builder = null; ViewGroup list = mPopup.getListView(); for (int i = 0; i < list.getChildCount(); i++) { View view = list.getChildAt(i); Object animatorObject = view.getTag(R.id.menu_item_enter_anim_id); if (animatorObject != null) { if (builder == null) { builder = mMenuItemEnterAnimator.play((Animator) animatorObject); } else { builder.with((Animator) animatorObject); } } } mMenuItemEnterAnimator.addListener(mAnimationHistogramRecorder); mMenuItemEnterAnimator.start(); }
/** * 初始化动画操作 */ private void initAnimator( ViewHolder holder){ ObjectAnimator mItem = ObjectAnimator.ofFloat(holder.itemView, "translationX",0f, -60f); ObjectAnimator scaleX = ObjectAnimator.ofFloat(holder.mImage, "scaleX",1f, 0f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(holder.mImage, "scaleY",1f, 0f); AnimatorSet animSet = new AnimatorSet(); animSet.play(mItem).with(scaleX).with(scaleY); animSet.setDuration(0); animSet.start(); }
/** * 开始播放连击动画 */ public AnimatorSet startNumberComboAnimation() { if (onAnimationListener != null) { onAnimationListener.onGiftAnimationCombo(mComboCurrentCount); } if (mAnimation == null) { return mDefaultAnimation.giftNumberComboAnimation(this, holder, mComboCurrentCount); } return mAnimation.giftNumberComboAnimation(this, holder, mComboCurrentCount); }
/** * Plays together all animations passed in as parameter. Once animation is * completed, r.run() is executed. If parameter isReset is set to true, * {@link #mSelectedCardPosition} is set to {@link #INVALID_CARD_POSITION} * * @param animations * @param r * @param isReset */ private void startAnimations(List<Animator> animations, final Runnable r, final boolean isReset) { AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(animations); animatorSet.setDuration(ANIM_DURATION); animatorSet.setInterpolator(new DecelerateInterpolator(DECELERATION_FACTOR)); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (r != null) r.run(); setScreenTouchable(true); if (isReset) mSelectedCardPosition = INVALID_CARD_POSITION; } }); animatorSet.start(); }
private void initAnimation() { List<Animator> animators = new ArrayList<>(); // horizontal animation. // wave waves infinitely. ObjectAnimator waveShiftAnim = ObjectAnimator.ofFloat( mWaveView, "waveShiftRatio", 0f, 1f); waveShiftAnim.setRepeatCount(ValueAnimator.INFINITE); waveShiftAnim.setDuration(1000); waveShiftAnim.setInterpolator(new LinearInterpolator()); animators.add(waveShiftAnim); // vertical animation. // water level increases from 0 to center of WaveView ObjectAnimator waterLevelAnim = ObjectAnimator.ofFloat( mWaveView, "waterLevelRatio", 0f, 0.5f); waterLevelAnim.setDuration(1000); waterLevelAnim.setInterpolator(new DecelerateInterpolator()); animators.add(waterLevelAnim); // amplitude animation. // wave grows big then grows small, repeatedly ObjectAnimator amplitudeAnim = ObjectAnimator.ofFloat( mWaveView, "amplitudeRatio", 0.0001f, 0.05f); amplitudeAnim.setRepeatCount(ValueAnimator.INFINITE); amplitudeAnim.setRepeatMode(ValueAnimator.REVERSE); amplitudeAnim.setDuration(5000); amplitudeAnim.setInterpolator(new LinearInterpolator()); animators.add(amplitudeAnim); mAnimatorSet = new AnimatorSet(); mAnimatorSet.playTogether(animators); }
public AnimatorSet createDefaultColorChangeAnimatorSet(int newColor) { Animator backgroundAnimator = ViewUtil.createBackgroundColorTransition(fragment.playbackControlsFragment.getView(), fragment.lastColor, newColor); Animator statusBarAnimator = ViewUtil.createBackgroundColorTransition(fragment.playerStatusBar, fragment.lastColor, newColor); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(backgroundAnimator, statusBarAnimator); if (!ATHUtil.isWindowBackgroundDark(fragment.getActivity())) { int adjustedLastColor = ColorUtil.isColorLight(fragment.lastColor) ? ColorUtil.darkenColor(fragment.lastColor) : fragment.lastColor; int adjustedNewColor = ColorUtil.isColorLight(newColor) ? ColorUtil.darkenColor(newColor) : newColor; Animator subHeaderAnimator = ViewUtil.createTextColorTransition(fragment.playerQueueSubHeader, adjustedLastColor, adjustedNewColor); animatorSet.play(subHeaderAnimator); } animatorSet.setDuration(ViewUtil.PHONOGRAPH_ANIM_TIME); return animatorSet; }
public AnimatorSetProxy() { if (View10.NEED_PROXY) { animatorSet = new AnimatorSet10(); } else { animatorSet = new AnimatorSet(); } }