List of usage examples for android.animation ValueAnimator getAnimatedValue
public Object getAnimatedValue()
ValueAnimator
when there is just one property being animated. From source file:xyz.klinker.blur.launcher3.Launcher.java
@Override public void onRestoreInstanceState(Bundle state) { super.onRestoreInstanceState(state); for (int page : mSynchronouslyBoundPages) { mWorkspace.restoreInstanceStateForChild(page); }//from ww w. j a v a 2 s . c o m if (mLauncherDrawer.isDrawerOpen(Gravity.START)) { if (Utilities.ATLEAST_MARSHMALLOW) { mLauncherDrawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } if (Utilities.ATLEAST_LOLLIPOP) { ValueAnimator animator = ValueAnimator.ofArgb(Color.TRANSPARENT, Color.parseColor("#22000000")); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int color = (Integer) valueAnimator.getAnimatedValue(); getWindow().setNavigationBarColor(color); getWindow().setStatusBarColor(color); } }); animator.setDuration(300); animator.start(); } } }
From source file:com.android.launcher3.Workspace.java
private void animateBackgroundGradient(float finalAlpha, boolean animated) { final DragLayer dragLayer = mLauncher.getDragLayer(); if (mBackgroundFadeInAnimation != null) { mBackgroundFadeInAnimation.cancel(); mBackgroundFadeInAnimation = null; }//from w w w . j a v a 2 s . c om if (mBackgroundFadeOutAnimation != null) { mBackgroundFadeOutAnimation.cancel(); mBackgroundFadeOutAnimation = null; } float startAlpha = dragLayer.getBackgroundAlpha(); if (finalAlpha != startAlpha) { if (animated) { mBackgroundFadeOutAnimation = LauncherAnimUtils.ofFloat(this, startAlpha, finalAlpha); mBackgroundFadeOutAnimation.addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { dragLayer.setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue()); } }); mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION); mBackgroundFadeOutAnimation.start(); } else { dragLayer.setBackgroundAlpha(finalAlpha); } } }
From source file:com.android.soma.Launcher.java
private void showAppsCustomizeHelper(final boolean animated, final boolean springLoaded, final AppsCustomizePagedView.ContentType contentType) { if (mStateAnimation != null) { mStateAnimation.setDuration(0);/*from ww w. j a v a 2 s. c o m*/ mStateAnimation.cancel(); mStateAnimation = null; } final Resources res = getResources(); final int duration = res.getInteger(R.integer.config_appsCustomizeZoomInTime); final int fadeDuration = res.getInteger(R.integer.config_appsCustomizeFadeInTime); final float scale = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor); final View fromView = mWorkspace; final AppsCustomizeTabHost toView = mAppsCustomizeTabHost; final int startDelay = res.getInteger(R.integer.config_workspaceAppsCustomizeAnimationStagger); setPivotsForZoom(toView, scale); // Shrink workspaces away if going to AppsCustomize from workspace Animator workspaceAnim = mWorkspace.getChangeStateAnimation(Workspace.State.SMALL, animated); if (!AppsCustomizePagedView.DISABLE_ALL_APPS) { // Set the content type for the all apps space mAppsCustomizeTabHost.setContentTypeImmediate(contentType); } if (animated) { toView.setScaleX(scale); toView.setScaleY(scale); final LauncherViewPropertyAnimator scaleAnim = new LauncherViewPropertyAnimator(toView); scaleAnim.scaleX(1f).scaleY(1f).setDuration(duration) .setInterpolator(new Workspace.ZoomOutInterpolator()); toView.setVisibility(View.VISIBLE); toView.setAlpha(0f); final ObjectAnimator alphaAnim = LauncherAnimUtils.ofFloat(toView, "alpha", 0f, 1f) .setDuration(fadeDuration); alphaAnim.setInterpolator(new DecelerateInterpolator(1.5f)); alphaAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation == null) { throw new RuntimeException("animation is null"); } float t = (Float) animation.getAnimatedValue(); dispatchOnLauncherTransitionStep(fromView, t); dispatchOnLauncherTransitionStep(toView, t); } }); // toView should appear right at the end of the workspace shrink // animation mStateAnimation = LauncherAnimUtils.createAnimatorSet(); mStateAnimation.play(scaleAnim).after(startDelay); mStateAnimation.play(alphaAnim).after(startDelay); mStateAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { // Prepare the position toView.setTranslationX(0.0f); toView.setTranslationY(0.0f); toView.setVisibility(View.VISIBLE); toView.bringToFront(); } @Override public void onAnimationEnd(Animator animation) { dispatchOnLauncherTransitionEnd(fromView, animated, false); dispatchOnLauncherTransitionEnd(toView, animated, false); // Hide the search bar if (mSearchDropTargetBar != null) { mSearchDropTargetBar.hideSearchBar(false); } } }); if (workspaceAnim != null) { mStateAnimation.play(workspaceAnim); } boolean delayAnim = false; dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionPrepare(toView, animated, false); // If any of the objects being animated haven't been measured/laid out // yet, delay the animation until we get a layout pass if ((((LauncherTransitionable) toView).getContent().getMeasuredWidth() == 0) || (mWorkspace.getMeasuredWidth() == 0) || (toView.getMeasuredWidth() == 0)) { delayAnim = true; } 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; setPivotsForZoom(toView, scale); dispatchOnLauncherTransitionStart(fromView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); LauncherAnimUtils.startAnimationAfterNextDraw(mStateAnimation, toView); } }; if (delayAnim) { final ViewTreeObserver observer = toView.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { public void onGlobalLayout() { startAnimRunnable.run(); toView.getViewTreeObserver().removeOnGlobalLayoutListener(this); } }); } else { startAnimRunnable.run(); } } else { toView.setTranslationX(0.0f); toView.setTranslationY(0.0f); toView.setScaleX(1.0f); toView.setScaleY(1.0f); toView.setVisibility(View.VISIBLE); toView.bringToFront(); if (!springLoaded && !LauncherAppState.getInstance().isScreenLarge()) { // Hide the search bar if (mSearchDropTargetBar != null) { mSearchDropTargetBar.hideSearchBar(false); } } dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionStart(fromView, animated, false); dispatchOnLauncherTransitionEnd(fromView, animated, false); dispatchOnLauncherTransitionPrepare(toView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); dispatchOnLauncherTransitionEnd(toView, animated, false); } }
From source file:xyz.klinker.blur.launcher3.Launcher.java
private void setupDrawer() { mWorkspace.setOnPageChangedListener(new Workspace.OnPageChangeListener() { @Override/* w w w .j a v a 2 s .c o m*/ public void onPageChanged(int page) { if (mLauncherDrawer == null) { return; } if (mLauncherDrawer.getDrawerLockMode(Gravity.LEFT) == LauncherDrawerLayout.LOCK_MODE_LOCKED_CLOSED && !mWorkspace.isSmall()) { lockLauncherDrawer(false); } if (page == 0) { // on the first page mLauncherDrawer.setDrawerLeftEdgeSize(Launcher.this, 1.0f); } else { // somewhere in the middle mLauncherDrawer.setDrawerLeftEdgeSize(Launcher.this, .07f); } } @Override public void onScrollStart() { lockLauncherDrawer(true); } @Override public void onScrollEnd() { } }); mDrawerPager.setPageMargin(Utils.toDP(this, 15)); mDrawerPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { mLauncherDrawer.setCurrentDrawerPage(position); } }); mLauncherDrawer.setDrawerListener(new LauncherDrawerLayout.DrawerListener() { @Override public void onDrawerSlide(View drawerView, float slideOffset) { mDragLayer.setTranslationX(getScreenWidth() * slideOffset); ((PagesFragmentAdapter) mDrawerPager.getAdapter()) .adjustFragmentBackgroundAlpha(mDrawerPager.getCurrentItem(), slideOffset); } @Override public void onDrawerOpened(View drawerView) { if (drawerView == mDrawerPager) { mDragLayer.setTranslationX(getScreenWidth()); } else { mDragLayer.setTranslationX(getScreenWidth() * -1); } adapter.pagesOpened(); if (Utilities.ATLEAST_MARSHMALLOW) { mLauncherDrawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } if (Utilities.ATLEAST_LOLLIPOP) { ValueAnimator animator = ValueAnimator.ofArgb(Color.TRANSPARENT, Color.parseColor("#22000000")); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int color = (Integer) valueAnimator.getAnimatedValue(); getWindow().setNavigationBarColor(color); getWindow().setStatusBarColor(color); } }); animator.setDuration(300); animator.start(); } } @Override public void onDrawerClosed(View drawerView) { mDragLayer.setTranslationX(0); adapter.pagesClosed(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mLauncherDrawer.getWindowToken(), 0); if (Utilities.ATLEAST_MARSHMALLOW) { mLauncherDrawer.setSystemUiVisibility( mLauncherDrawer.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } if (Utilities.ATLEAST_LOLLIPOP) { ValueAnimator animator = ValueAnimator.ofArgb(Color.parseColor("#22000000"), Color.TRANSPARENT); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int color = (Integer) valueAnimator.getAnimatedValue(); getWindow().setNavigationBarColor(color); getWindow().setStatusBarColor(color); } }); animator.setDuration(300); animator.start(); } } @Override public void onDrawerStateChanged(int newState) { } private int screenWidth = -1; private int getScreenWidth() { if (screenWidth == -1) { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); screenWidth = size.x; } return screenWidth; } }); }
From source file:com.joaquimley.birdsseyeview.activities.MapsActivity.java
/** * Google Map animation listener mAnimatorSet *///from w ww. ja v a2s. co m @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { mMap.moveCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder(mMap.getCameraPosition()) .bearing((Float) valueAnimator.getAnimatedValue()).build())); }