List of usage examples for android.animation ValueAnimator setDuration
@Override public ValueAnimator setDuration(long duration)
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 w w w . ja va2 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:xyz.klinker.blur.launcher3.Launcher.java
private void setupDrawer() { mWorkspace.setOnPageChangedListener(new Workspace.OnPageChangeListener() { @Override/*from www .java 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; } }); }