List of usage examples for android.animation ObjectAnimator setDuration
@Override @NonNull public ObjectAnimator setDuration(long duration)
From source file:com.bookkos.bircle.CaptureActivity.java
private void animateTranslationX(View target) { // translationX0f?200f????? ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(target, "translationX", 0f, 200f); // 1???//from ww w.j a v a 2s. co m objectAnimator.setDuration(1000); // ??? objectAnimator.start(); }
From source file:com.bookkos.bircle.CaptureActivity.java
private void animateTranslationY(View target, float start_height, float end_height) { // translationY????(ON) ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(target, "translationY", start_height, end_height); // 1???// w w w.j a va2 s . c o m objectAnimator.setDuration(300); // ??? objectAnimator.start(); }
From source file:com.gigabytedevelopersinc.app.calculator.Calculator.java
private void dismissCling(final Cling cling, final String flag, int duration) { setPagingEnabled(true);//from w w w .j a v a 2 s . c om clingActive = false; if (cling != null) { cling.dismiss(); if (getActionBar() != null) { getActionBar().show(); } getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#FFFFFF"))); ObjectAnimator anim = ObjectAnimator.ofFloat(cling, "alpha", 0f); anim.setDuration(duration); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { cling.setVisibility(View.GONE); cling.cleanup(); CalculatorSettings.saveKey(getContext(), flag, true); } }); anim.start(); } }
From source file:com.auratech.launcher.Folder.java
public void animateOpen() { positionAndSizeAsIcon();//from w ww. j a v a 2 s . co m if (!(getParent() instanceof DragLayer)) return; centerAboutIcon(); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, String.format(getContext().getString(R.string.folder_opened), mContent.getCountX(), mContent.getCountY())); mState = STATE_ANIMATING; } @Override public void onAnimationEnd(Animator animation) { mState = STATE_OPEN; setLayerType(LAYER_TYPE_NONE, null); // Only show cling if we are not in the middle of a drag - this would be quite jarring. if (!mDragController.isDragging()) { Cling cling = mLauncher.getLauncherClings().showFoldersCling(); if (cling != null) { cling.bringScrimToFront(); bringToFront(); cling.bringToFront(); } } setFocusOnFirstChild(); } }); oa.setDuration(mExpandDuration); setLayerType(LAYER_TYPE_HARDWARE, null); oa.start(); // Make sure the folder picks up the last drag move even if the finger doesn't move. if (mDragController.isDragging()) { mDragController.forceTouchMove(); } }
From source file:com.fairphone.fplauncher3.Folder.java
public void animateClosed() { if (!(getParent() instanceof DragLayer)) { return;//from w w w .j ava2 s. co m } PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.9f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.9f); /*final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);*/ setLayerType(LAYER_TYPE_HARDWARE, null); float animatorDurationScale = Settings.Global.getFloat(getContext().getContentResolver(), Settings.Global.ANIMATOR_DURATION_SCALE, 1); ObjectAnimator oa; if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mPowerManager.isPowerSaveMode()) || animatorDurationScale < 0.01f) { // power save mode is no fun - skip alpha animation and just set it to 0 // otherwise the icons will stay around until the duration of the animation oa = LauncherAnimUtils.ofPropertyValuesHolder(this, scaleX, scaleY); setAlpha(0f); } else { oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY); } oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { onCloseComplete(); setLayerType(LAYER_TYPE_NONE, null); mState = STATE_SMALL; } @Override public void onAnimationStart(Animator animation) { sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, getContext().getString(R.string.folder_closed)); mState = STATE_ANIMATING; } }); oa.setDuration(mExpandDuration); setLayerType(LAYER_TYPE_HARDWARE, null); oa.start(); }
From source file:com.android.contacts.quickcontact.QuickContactActivity.java
private void updateStatusBarColor() { if (mScroller == null || !CompatUtils.isLollipopCompatible()) { return;/*w w w . ja v a 2 s .com*/ } final int desiredStatusBarColor; // Only use a custom status bar color if QuickContacts touches the top of the viewport. if (mScroller.getScrollNeededToBeFullScreen() <= 0) { desiredStatusBarColor = mStatusBarColor; } else { desiredStatusBarColor = Color.TRANSPARENT; } // Animate to the new color. final ObjectAnimator animation = ObjectAnimator.ofInt(getWindow(), "statusBarColor", getWindow().getStatusBarColor(), desiredStatusBarColor); animation.setDuration(ANIMATION_STATUS_BAR_COLOR_CHANGE_DURATION); animation.setEvaluator(new ArgbEvaluator()); animation.start(); }
From source file:com.amaze.filemanager.activities.MainActivity.java
void revealShow(final View view, boolean reveal) { if (reveal) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 0f, 1f); animator.setDuration(300); //ms animator.addListener(new AnimatorListenerAdapter() { @Override//from w w w. ja va2s .c o m public void onAnimationStart(Animator animation) { view.setVisibility(View.VISIBLE); } }); animator.start(); } else { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 1f, 0f); animator.setDuration(300); //ms animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.GONE); } }); animator.start(); } }
From source file:com.aliyun.homeshell.Folder.java
public void backFromSelectApps() { if (mRunningAnimatorSet != null) { if (mRunningIsShow) { mRunningAnimatorSet.end();/*w w w . java 2 s .c o m*/ } else { return; } } ObjectAnimator invisToVis = ObjectAnimator.ofFloat(this, "alpha", 0, 1); invisToVis.setDuration(mAnimatorDuration); ObjectAnimator visToInvisX = ObjectAnimator.ofFloat(mAppsSelectView, "scaleX", 1, 0); visToInvisX.setDuration(mAnimatorDuration); ObjectAnimator visToInvisY = ObjectAnimator.ofFloat(mAppsSelectView, "scaleY", 1, 0); visToInvisY.setDuration(mAnimatorDuration); List<Animator> animList = new ArrayList<Animator>(); animList.add(invisToVis); animList.add(visToInvisX); animList.add(visToInvisY); final AnimatorSet as = new AnimatorSet(); as.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { Folder.this.setVisibility(View.VISIBLE); mRunningAnimatorSet = as; mRunningIsShow = false; /*YUNOS BEGIN*/ //##date:2014/06/27 ##author:yangshan.ys@alibaba-inc.com##BugID:132255 //when back to folder from folderappsselectview ,prevent the mFolderName from getting focus mFolderName.setFocusable(false); /* YUNOS END */ } @Override public void onAnimationEnd(Animator animator) { mRunningAnimatorSet = null; mRunningIsShow = false; mAppsSelectView.setVisibility(View.INVISIBLE); Folder.this.setVisibility(View.VISIBLE); /*YUNOS BEGIN*/ //##date:2014/06/27 ##author:yangshan.ys@alibaba-inc.com##BugID:132255 //when back to folder from folderappsselectview ,prevent the mFolderName from getting focus mFolderName.setFocusable(true); /*YUNOS BEGIN*/ //##date:2014/06/27 ##author:yangshan.ys@alibaba-inc.com##BugID:133680 //when back to folder from folderappsselectview, the folderName cannot be changed mFolderName.setFocusableInTouchMode(true); /* YUNOS END */ /* YUNOS END */ mIsEditingName = false; } }); as.playTogether(animList); as.start(); }
From source file:com.aliyun.homeshell.Folder.java
public void showSelectApps(int[] pos) { if (mRunningAnimatorSet != null) { if (!mRunningIsShow) { mRunningAnimatorSet.end();//from w w w . java 2 s.c o m } else { return; } } if (mAppsSelectView == null) { mAppsSelectView = (FolderAppsSelectView) LayoutInflater.from(getContext()) .inflate(R.layout.folder_apps_select, null); mAppsSelectView.init(this, mInfo, mLauncher); mLauncher.getDragLayer().addView(mAppsSelectView); } mAppsSelectView.initSelectedState(mInfo); mAppsSelectView.setScaleX(0); mAppsSelectView.setScaleY(0); mAppsSelectView.setPivotX(pos[0]); mAppsSelectView.setPivotY(pos[1]); ObjectAnimator visToInvis = ObjectAnimator.ofFloat(this, "alpha", 1, 0); visToInvis.setDuration(mAnimatorDuration); ObjectAnimator invisToVisX = ObjectAnimator.ofFloat(mAppsSelectView, "scaleX", 0, 1); invisToVisX.setDuration(mAnimatorDuration); ObjectAnimator invisToVisY = ObjectAnimator.ofFloat(mAppsSelectView, "scaleY", 0, 1); invisToVisY.setDuration(mAnimatorDuration); List<Animator> animList = new ArrayList<Animator>(); animList.add(visToInvis); animList.add(invisToVisX); animList.add(invisToVisY); final AnimatorSet as = new AnimatorSet(); as.setInterpolator(new LinearInterpolator()); as.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { mAppsSelectView.setVisibility(View.VISIBLE); mRunningAnimatorSet = as; mRunningIsShow = true; } @Override public void onAnimationEnd(Animator animator) { mRunningAnimatorSet = null; mRunningIsShow = false; Folder.this.setVisibility(View.INVISIBLE); mAppsSelectView.setVisibility(View.VISIBLE); DisplayMetrics metric = new DisplayMetrics(); mLauncher.getWindowManager().getDefaultDisplay().getMetrics(metric); int width = metric.widthPixels; int height = metric.heightPixels; mAppsSelectView.setPivotX(width / 2); mAppsSelectView.setPivotY(height / 2); mAppsSelectView.setFocusableInTouchMode(true); mAppsSelectView.setFocusable(true); mAppsSelectView.requestFocus(); } }); as.playTogether(animList); as.start(); }
From source file:com.android.leanlauncher.LauncherTransitionable.java
/** * Zoom the camera back into the workspace, hiding 'fromView'. * This is the opposite of showAppsCustomizeHelper. * * @param animated If true, the transition will be animated. *//*from ww w . j a v a 2 s .com*/ private void hideAppsCustomizeHelper(Workspace.State toState, final boolean animated, final boolean springLoaded, final Runnable onCompleteRunnable) { if (mStateAnimation != null) { mStateAnimation.setDuration(0); mStateAnimation.cancel(); mStateAnimation = null; } boolean material = Utilities.isLmpOrAbove(); Resources res = getResources(); final int revealDuration = res.getInteger(R.integer.config_appsCustomizeConcealTime); final int itemsAlphaStagger = res.getInteger(R.integer.config_appsCustomizeItemsAlphaStagger); final View fromView = mAppsCustomizeTabHost; final View toView = mWorkspace; Animator workspaceAnim = null; final ArrayList<View> layerViews = new ArrayList<View>(); if (toState == Workspace.State.NORMAL) { workspaceAnim = mWorkspace.getChangeStateAnimation(toState, animated, layerViews); } else if (toState == Workspace.State.SPRING_LOADED || toState == Workspace.State.OVERVIEW) { workspaceAnim = mWorkspace.getChangeStateAnimation(toState, animated, layerViews); } // If for some reason our views aren't initialized, don't animate boolean initialized = getAllAppsButton() != null; if (animated && initialized) { mStateAnimation = LauncherAnimUtils.createAnimatorSet(); if (workspaceAnim != null) { mStateAnimation.play(workspaceAnim); } final AppsCustomizePagedView content = (AppsCustomizePagedView) fromView .findViewById(R.id.apps_customize_pane_content); final View page = content.getPageAt(content.getNextPage()); // We need to hide side pages of the Apps / Widget tray to avoid some ugly edge cases int count = content.getChildCount(); for (int i = 0; i < count; i++) { View child = content.getChildAt(i); if (child != page) { child.setVisibility(View.INVISIBLE); } } final View revealView = fromView.findViewById(R.id.fake_page); // hideAppsCustomizeHelper is called in some cases when it is already hidden // don't perform all these no-op animations. In particularly, this was causing // the all-apps button to pop in and out. if (fromView.getVisibility() == View.VISIBLE) { AppsCustomizePagedView.ContentType contentType = content.getContentType(); final boolean isWidgetTray = contentType == AppsCustomizePagedView.ContentType.Widgets; revealView.setBackgroundColor(getResources().getColor(R.color.widget_text_panel)); int width = revealView.getMeasuredWidth(); int height = revealView.getMeasuredHeight(); float revealRadius = (float) Math.sqrt((width * width) / 4 + (height * height) / 4); // Hide the real page background, and swap in the fake one revealView.setVisibility(View.VISIBLE); content.setPageBackgroundsVisible(false); final View allAppsButton = getAllAppsButton(); revealView.setTranslationY(0); int[] allAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView, allAppsButton, null); float xDrift = 0; float yDrift = 0; if (material) { yDrift = isWidgetTray ? height / 2 : allAppsToPanelDelta[1]; xDrift = isWidgetTray ? 0 : allAppsToPanelDelta[0]; } else { yDrift = 2 * height / 3; xDrift = 0; } revealView.setLayerType(View.LAYER_TYPE_HARDWARE, null); TimeInterpolator decelerateInterpolator = material ? new LogDecelerateInterpolator(100, 0) : new DecelerateInterpolator(1f); // The vertical motion of the apps panel should be delayed by one frame // from the conceal animation in order to give the right feel. We correpsondingly // shorten the duration so that the slide and conceal end at the same time. ObjectAnimator panelDriftY = LauncherAnimUtils.ofFloat(revealView, "translationY", 0, yDrift); panelDriftY.setDuration(revealDuration - SINGLE_FRAME_DELAY); panelDriftY.setStartDelay(itemsAlphaStagger + SINGLE_FRAME_DELAY); panelDriftY.setInterpolator(decelerateInterpolator); mStateAnimation.play(panelDriftY); ObjectAnimator panelDriftX = LauncherAnimUtils.ofFloat(revealView, "translationX", 0, xDrift); panelDriftX.setDuration(revealDuration - SINGLE_FRAME_DELAY); panelDriftX.setStartDelay(itemsAlphaStagger + SINGLE_FRAME_DELAY); panelDriftX.setInterpolator(decelerateInterpolator); mStateAnimation.play(panelDriftX); if (isWidgetTray || !material) { float finalAlpha = material ? 0.4f : 0f; revealView.setAlpha(1f); ObjectAnimator panelAlpha = LauncherAnimUtils.ofFloat(revealView, "alpha", 1f, finalAlpha); panelAlpha.setDuration(material ? revealDuration : 150); panelAlpha.setInterpolator(decelerateInterpolator); panelAlpha.setStartDelay(material ? 0 : itemsAlphaStagger + SINGLE_FRAME_DELAY); mStateAnimation.play(panelAlpha); } if (page != null) { page.setLayerType(View.LAYER_TYPE_HARDWARE, null); ObjectAnimator pageDrift = LauncherAnimUtils.ofFloat(page, "translationY", 0, yDrift); page.setTranslationY(0); pageDrift.setDuration(revealDuration - SINGLE_FRAME_DELAY); pageDrift.setInterpolator(decelerateInterpolator); pageDrift.setStartDelay(itemsAlphaStagger + SINGLE_FRAME_DELAY); mStateAnimation.play(pageDrift); page.setAlpha(1f); ObjectAnimator itemsAlpha = LauncherAnimUtils.ofFloat(page, "alpha", 1f, 0f); itemsAlpha.setDuration(100); itemsAlpha.setInterpolator(decelerateInterpolator); mStateAnimation.play(itemsAlpha); } View pageIndicators = fromView.findViewById(R.id.apps_customize_page_indicator); pageIndicators.setAlpha(1f); ObjectAnimator indicatorsAlpha = LauncherAnimUtils.ofFloat(pageIndicators, "alpha", 0f); indicatorsAlpha.setDuration(revealDuration); indicatorsAlpha.setInterpolator(new DecelerateInterpolator(1.5f)); mStateAnimation.play(indicatorsAlpha); width = revealView.getMeasuredWidth(); if (material) { if (!isWidgetTray) { allAppsButton.setVisibility(View.INVISIBLE); } int allAppsButtonSize = LauncherAppState.getInstance().getDynamicGrid() .getDeviceProfile().allAppsButtonVisualSize; float finalRadius = isWidgetTray ? 0 : allAppsButtonSize / 2; Animator reveal = LauncherAnimUtils.createCircularReveal(revealView, width / 2, height / 2, revealRadius, finalRadius); reveal.setInterpolator(new LogDecelerateInterpolator(100, 0)); reveal.setDuration(revealDuration); reveal.setStartDelay(itemsAlphaStagger); reveal.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animation) { revealView.setVisibility(View.INVISIBLE); if (!isWidgetTray) { allAppsButton.setVisibility(View.VISIBLE); } } }); mStateAnimation.play(reveal); } dispatchOnLauncherTransitionPrepare(fromView, animated, true); dispatchOnLauncherTransitionPrepare(toView, animated, true); mAppsCustomizeContent.stopScrolling(); } mStateAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { fromView.setVisibility(View.GONE); dispatchOnLauncherTransitionEnd(fromView, animated, true); dispatchOnLauncherTransitionEnd(toView, animated, true); if (onCompleteRunnable != null) { onCompleteRunnable.run(); } revealView.setLayerType(View.LAYER_TYPE_NONE, null); if (page != null) { page.setLayerType(View.LAYER_TYPE_NONE, null); } content.setPageBackgroundsVisible(true); // Unhide side pages int count = content.getChildCount(); for (int i = 0; i < count; i++) { View child = content.getChildAt(i); child.setVisibility(View.VISIBLE); } // Reset page transforms if (page != null) { page.setTranslationX(0); page.setTranslationY(0); page.setAlpha(1); } content.setCurrentPage(content.getNextPage()); mAppsCustomizeContent.updateCurrentPageScroll(); // This can hold unnecessary references to views. mStateAnimation = null; } }); final AnimatorSet stateAnimation = mStateAnimation; final Runnable startAnimRunnable = new Runnable() { public void run() { // Check that mStateAnimation hasn't changed while // we waited for a layout/draw pass if (mStateAnimation != stateAnimation) return; dispatchOnLauncherTransitionStart(fromView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); if (Utilities.isLmpOrAbove()) { for (int i = 0; i < layerViews.size(); i++) { View v = layerViews.get(i); if (v != null) { if (Utilities.isViewAttachedToWindow(v)) v.buildLayer(); } } } mStateAnimation.start(); } }; fromView.post(startAnimRunnable); } else { fromView.setVisibility(View.GONE); dispatchOnLauncherTransitionPrepare(fromView, animated, true); dispatchOnLauncherTransitionStart(fromView, animated, true); dispatchOnLauncherTransitionEnd(fromView, animated, true); dispatchOnLauncherTransitionPrepare(toView, animated, true); dispatchOnLauncherTransitionStart(toView, animated, true); dispatchOnLauncherTransitionEnd(toView, animated, true); } }