List of usage examples for android.view.animation AccelerateInterpolator AccelerateInterpolator
public AccelerateInterpolator(float factor)
From source file:com.aniruddhc.acemusic.player.BrowserSubGridActivity.BrowserSubGridActivity.java
/** * Slides away the header layout./*from ww w . ja v a 2s.c o m*/ */ private void slideAwayHeader() { TranslateAnimation slideDown = new TranslateAnimation(mHeaderLayout, 400, new AccelerateInterpolator(2.0f), View.INVISIBLE, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -2.0f); slideDown.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mHeaderLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { mHeaderLayout.setVisibility(View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); slideDown.animate(); }
From source file:com.aniruddhc.acemusic.player.BrowserSubListActivity.BrowserSubListActivity.java
/** * Slides away the GridView.//from w ww .j a va 2 s. c o m */ private void slideAwayGridView() { android.view.animation.TranslateAnimation animation = new android.view.animation.TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 2.0f); animation.setDuration(400); animation.setInterpolator(new AccelerateInterpolator(2.0f)); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { mListView.setVisibility(View.INVISIBLE); BrowserSubListActivity.super.onBackPressed(); } @Override public void onAnimationRepeat(Animation arg0) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation arg0) { } }); mListView.startAnimation(animation); }
From source file:com.hippo.refreshlayout.RefreshLayout.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * * @param context/*www .ja va 2 s . co m*/ * @param attrs */ public RefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime); setWillNotDraw(false); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR); final DisplayMetrics metrics = getResources().getDisplayMetrics(); mCircleDiameter = (int) (CIRCLE_DIAMETER * metrics.density); createProgressView(); ViewCompat.setChildrenDrawingOrderEnabled(this, true); // the absolute offset has to take into account that the circle starts at an offset mHeaderSpinnerOffsetEnd = (int) (DEFAULT_CIRCLE_TARGET * metrics.density); mHeaderTotalDragDistance = mHeaderSpinnerOffsetEnd; mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true); mHeaderOriginalOffsetTop = mHeaderCurrentTargetOffsetTop = -mCircleDiameter; moveToStart(1.0f); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); setEnabled(a.getBoolean(0, true)); a.recycle(); mProgressBar = new SwipeProgressBar(this); mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT); }
From source file:com.aniruddhc.acemusic.player.BrowserSubGridActivity.BrowserSubGridActivity.java
/** * Slides away the GridView./*from ww w.j a v a 2 s.c o m*/ */ private void slideAwayGridView() { android.view.animation.TranslateAnimation animation = new android.view.animation.TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 2.0f); animation.setDuration(400); animation.setInterpolator(new AccelerateInterpolator(2.0f)); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { mGridView.setVisibility(View.INVISIBLE); BrowserSubGridActivity.super.onBackPressed(); } @Override public void onAnimationRepeat(Animation arg0) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation arg0) { } }); mGridView.startAnimation(animation); }
From source file:com.amaze.filemanager.fragments.RarViewer.java
public void createviews(ArrayList<FileHeader> zipEntries, String dir) { zipViewer.zipAdapter = new RarAdapter(zipViewer.getActivity(), zipEntries, zipViewer); zipViewer.listView.setAdapter(zipViewer.zipAdapter); if (!addheader) { listView.removeItemDecoration(dividerItemDecoration); listView.removeItemDecoration(headersDecor); addheader = true;/*from w w w. ja v a 2s .co m*/ } if (addheader) { dividerItemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST, false, showDividers); listView.addItemDecoration(dividerItemDecoration); headersDecor = new StickyRecyclerHeadersDecoration(zipAdapter); listView.addItemDecoration(headersDecor); addheader = false; } listView.setOnScrollListener(new HidingScrollListener(mToolbarHeight, hidemode) { @Override public void onMoved(int distance) { mToolbarContainer.setTranslationY(-distance); } @Override public void onShow() { mToolbarContainer.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start(); } @Override public void onHide() { mToolbarContainer.findViewById(R.id.lin).animate().translationY(-mToolbarHeight) .setInterpolator(new AccelerateInterpolator(2)).start(); } }); zipViewer.current = dir; zipViewer.bbar(); swipeRefreshLayout.setRefreshing(false); }
From source file:com.android.launcher3.Folder.java
public void animateOpen() { if (!(getParent() instanceof DragLayer)) return;/*from ww w . j a va 2s . c o m*/ Animator openFolderAnim = null; final Runnable onCompleteRunnable; if (!Utilities.isLmpOrAbove()) { positionAndSizeAsIcon(); 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.setDuration(mExpandDuration); openFolderAnim = oa; setLayerType(LAYER_TYPE_HARDWARE, null); onCompleteRunnable = new Runnable() { @Override public void run() { setLayerType(LAYER_TYPE_NONE, null); } }; } else { prepareReveal(); centerAboutIcon(); int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth(); int height = getFolderHeight(); float transX = -0.075f * (width / 2 - getPivotX()); float transY = -0.075f * (height / 2 - getPivotY()); setTranslationX(transX); setTranslationY(transY); PropertyValuesHolder tx = PropertyValuesHolder.ofFloat("translationX", transX, 0); PropertyValuesHolder ty = PropertyValuesHolder.ofFloat("translationY", transY, 0); int rx = (int) Math.max(Math.max(width - getPivotX(), 0), getPivotX()); int ry = (int) Math.max(Math.max(height - getPivotY(), 0), getPivotY()); float radius = (float) Math.sqrt(rx * rx + ry * ry); AnimatorSet anim = LauncherAnimUtils.createAnimatorSet(); Animator reveal = LauncherAnimUtils.createCircularReveal(this, (int) getPivotX(), (int) getPivotY(), 0, radius); reveal.setDuration(mMaterialExpandDuration); reveal.setInterpolator(new LogDecelerateInterpolator(100, 0)); mContent.setAlpha(0f); Animator iconsAlpha = LauncherAnimUtils.ofFloat(mContent, "alpha", 0f, 1f); iconsAlpha.setDuration(mMaterialExpandDuration); iconsAlpha.setStartDelay(mMaterialExpandStagger); iconsAlpha.setInterpolator(new AccelerateInterpolator(1.5f)); mFolderName.setAlpha(0f); Animator textAlpha = LauncherAnimUtils.ofFloat(mFolderName, "alpha", 0f, 1f); textAlpha.setDuration(mMaterialExpandDuration); textAlpha.setStartDelay(mMaterialExpandStagger); textAlpha.setInterpolator(new AccelerateInterpolator(1.5f)); Animator drift = LauncherAnimUtils.ofPropertyValuesHolder(this, tx, ty); drift.setDuration(mMaterialExpandDuration); drift.setStartDelay(mMaterialExpandStagger); drift.setInterpolator(new LogDecelerateInterpolator(60, 0)); anim.play(drift); anim.play(iconsAlpha); anim.play(textAlpha); anim.play(reveal); openFolderAnim = anim; mContent.setLayerType(LAYER_TYPE_HARDWARE, null); onCompleteRunnable = new Runnable() { @Override public void run() { mContent.setLayerType(LAYER_TYPE_NONE, null); } }; } openFolderAnim.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; if (onCompleteRunnable != null) { onCompleteRunnable.run(); } setFocusOnFirstChild(); } }); openFolderAnim.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.songcode.materialnotes.ui.NoteEditActivity.java
private void animateRevealHide(final View targetview, View startView) { if (isActionInsertOrEdit()) { int cx = startView.getLeft() + (startView.getWidth() / 2); //middle of button int cy = startView.getTop() + (startView.getHeight() / 2); //middle of button int radius = (int) Math.sqrt(Math.pow(cx, 2) + Math.pow(cy, 2)); //hypotenuse to top left Animator anim = ViewAnimationUtils.createCircularReveal(targetview, cx, cy, radius, 0); anim.addListener(new AnimatorListenerAdapter() { @Override// w ww. j a v a 2s . c om public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); targetview.setVisibility(View.INVISIBLE); } }); //anim.setInterpolator(new AccelerateInterpolator()); anim.setDuration(ANIM_DURATION); anim.start(); Integer colorTo = getResources().getColor(R.color.primaryColor); Integer colorFrom = getResources().getColor(android.R.color.white); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { targetview.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.setInterpolator(new AccelerateInterpolator(2)); colorAnimation.setDuration(ANIM_DURATION); colorAnimation.start(); } else if (isActionActionView()) { mAnimBackGroudView.animate().scaleX(1).scaleY(1).alpha(1).translationY(0).setDuration(ANIM_DURATION) .setInterpolator(new AccelerateInterpolator()).start(); mNoteEditor.animate().alpha(0).setDuration(100).start(); } }
From source file:com.android.launcher3.folder.Folder.java
public void animateOpen() { if (!(getParent() instanceof DragLayer)) return;/*from w ww . j a v a 2 s.c om*/ mContent.completePendingPageChanges(); if (!mDragInProgress) { // Open on the first page. mContent.snapToPageImmediately(0); } // This is set to true in close(), but isn't reset to false until onDropCompleted(). This // leads to an inconsistent state if you drag out of the folder and drag back in without // dropping. One resulting issue is that replaceFolderWithFinalItem() can be called twice. mDeleteFolderOnDropCompleted = false; Animator openFolderAnim = null; final Runnable onCompleteRunnable; if (!Utilities.ATLEAST_LOLLIPOP) { positionAndSizeAsIcon(); centerAboutIcon(); final ObjectAnimator oa = LauncherAnimUtils.ofViewAlphaAndScale(this, 1, 1, 1); oa.setDuration(mExpandDuration); openFolderAnim = oa; setLayerType(LAYER_TYPE_HARDWARE, null); onCompleteRunnable = new Runnable() { @Override public void run() { setLayerType(LAYER_TYPE_NONE, null); } }; } else { prepareReveal(); centerAboutIcon(); AnimatorSet anim = LauncherAnimUtils.createAnimatorSet(); int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth(); int height = getFolderHeight(); float transX = -0.075f * (width / 2 - getPivotX()); float transY = -0.075f * (height / 2 - getPivotY()); setTranslationX(transX); setTranslationY(transY); PropertyValuesHolder tx = PropertyValuesHolder.ofFloat(TRANSLATION_X, transX, 0); PropertyValuesHolder ty = PropertyValuesHolder.ofFloat(TRANSLATION_Y, transY, 0); Animator drift = ObjectAnimator.ofPropertyValuesHolder(this, tx, ty); drift.setDuration(mMaterialExpandDuration); drift.setStartDelay(mMaterialExpandStagger); drift.setInterpolator(new LogDecelerateInterpolator(100, 0)); int rx = (int) Math.max(Math.max(width - getPivotX(), 0), getPivotX()); int ry = (int) Math.max(Math.max(height - getPivotY(), 0), getPivotY()); float radius = (float) Math.hypot(rx, ry); Animator reveal = new CircleRevealOutlineProvider((int) getPivotX(), (int) getPivotY(), 0, radius) .createRevealAnimator(this); reveal.setDuration(mMaterialExpandDuration); reveal.setInterpolator(new LogDecelerateInterpolator(100, 0)); mContent.setAlpha(0f); Animator iconsAlpha = ObjectAnimator.ofFloat(mContent, "alpha", 0f, 1f); iconsAlpha.setDuration(mMaterialExpandDuration); iconsAlpha.setStartDelay(mMaterialExpandStagger); iconsAlpha.setInterpolator(new AccelerateInterpolator(1.5f)); mFooter.setAlpha(0f); Animator textAlpha = ObjectAnimator.ofFloat(mFooter, "alpha", 0f, 1f); textAlpha.setDuration(mMaterialExpandDuration); textAlpha.setStartDelay(mMaterialExpandStagger); textAlpha.setInterpolator(new AccelerateInterpolator(1.5f)); anim.play(drift); anim.play(iconsAlpha); anim.play(textAlpha); anim.play(reveal); openFolderAnim = anim; mContent.setLayerType(LAYER_TYPE_HARDWARE, null); mFooter.setLayerType(LAYER_TYPE_HARDWARE, null); onCompleteRunnable = new Runnable() { @Override public void run() { mContent.setLayerType(LAYER_TYPE_NONE, null); mFooter.setLayerType(LAYER_TYPE_NONE, null); mLauncher.getUserEventDispatcher().resetElapsedContainerMillis(); } }; } openFolderAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { Utilities.sendCustomAccessibilityEvent(Folder.this, AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, mContent.getAccessibilityDescription()); mState = STATE_ANIMATING; } @Override public void onAnimationEnd(Animator animation) { mState = STATE_OPEN; onCompleteRunnable.run(); mContent.setFocusOnFirstChild(); } }); // Footer animation if (mContent.getPageCount() > 1 && !mInfo.hasOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION)) { int footerWidth = mContent.getDesiredWidth() - mFooter.getPaddingLeft() - mFooter.getPaddingRight(); float textWidth = mFolderName.getPaint().measureText(mFolderName.getText().toString()); float translation = (footerWidth - textWidth) / 2; mFolderName.setTranslationX(mContent.mIsRtl ? -translation : translation); mPageIndicator.prepareEntryAnimation(); // Do not update the flag if we are in drag mode. The flag will be updated, when we // actually drop the icon. final boolean updateAnimationFlag = !mDragInProgress; openFolderAnim.addListener(new AnimatorListenerAdapter() { @SuppressLint("InlinedApi") @Override public void onAnimationEnd(Animator animation) { mFolderName.animate().setDuration(FOLDER_NAME_ANIMATION_DURATION).translationX(0) .setInterpolator(Utilities.ATLEAST_LOLLIPOP ? AnimationUtils.loadInterpolator(mLauncher, android.R.interpolator.fast_out_slow_in) : new LogDecelerateInterpolator(100, 0)); mPageIndicator.playEntryAnimation(); if (updateAnimationFlag) { mInfo.setOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION, true, mLauncher); } } }); } else { mFolderName.setTranslationX(0); } mPageIndicator.stopAllAnimations(); openFolderAnim.start(); // Make sure the folder picks up the last drag move even if the finger doesn't move. if (mDragController.isDragging()) { mDragController.forceTouchMove(); } mContent.verifyVisibleHighResIcons(mContent.getNextPage()); }
From source file:com.android.systemui.statusbar.phone.NavigationBarView.java
public void setLowProfile(final boolean lightsOut, final boolean animate, final boolean force) { if (!force && lightsOut == mLowProfile) return;/*from w w w .ja v a 2 s. co m*/ mLowProfile = lightsOut; if (DEBUG) Slog.d(TAG, "setting lights " + (lightsOut ? "out" : "on")); final View navButtons = mCurrentView.findViewById(R.id.nav_buttons); final View lowLights = mCurrentView.findViewById(R.id.lights_out); // ok, everyone, stop it right there navButtons.animate().cancel(); lowLights.animate().cancel(); if (!animate) { navButtons.setAlpha(lightsOut ? 0f : 1f); lowLights.setAlpha(lightsOut ? 1f : 0f); lowLights.setVisibility(lightsOut ? View.VISIBLE : View.GONE); } else { navButtons.animate().alpha(lightsOut ? 0f : 1f).setDuration(lightsOut ? 750 : 250).start(); lowLights.setOnTouchListener(mLightsOutListener); if (lowLights.getVisibility() == View.GONE) { lowLights.setAlpha(0f); lowLights.setVisibility(View.VISIBLE); } lowLights.animate().alpha(lightsOut ? 1f : 0f).setDuration(lightsOut ? 750 : 250) .setInterpolator(new AccelerateInterpolator(2.0f)) .setListener(lightsOut ? null : new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator _a) { lowLights.setVisibility(View.GONE); } }).start(); } }
From source file:com.juick.android.ThreadFragment.java
private void closeNavigationMenu() { navigationMenuShown = false;//from w w w . j av a 2 s . co m for (int i = 0; i < flyingItems.length; i++) { final FlyingItem item = flyingItems[i]; item.setVisibility(View.VISIBLE); item.ani = new TranslateAnimation(Animation.ABSOLUTE, 0, Animation.ABSOLUTE, -item.designedX + item.widget.getWidth() * 1.5f, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, -item.designedY); item.ani.setDuration(500); item.ani.setInterpolator(new AccelerateInterpolator(1)); item.ani.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { //To change body of implemented methods use File | Settings | File Templates. } @Override public void onAnimationEnd(Animation animation) { item.setVisibility(View.GONE); item.widget.clearAnimation(); item.widget.disableReposition = false; item.widget.layout(item.originalHitRect.left, item.originalHitRect.top, item.originalHitRect.right, item.originalHitRect.bottom); if (item == flyingItems[0]) { TranslateAnimation aniIn = new TranslateAnimation(Animation.ABSOLUTE, 600, Animation.ABSOLUTE, initNavMenuTranslationX, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0); aniIn.setInterpolator(new DecelerateInterpolator(1)); item.ani.setDuration(500); aniIn.setFillAfter(true); navMenu.startAnimation(aniIn); } } @Override public void onAnimationRepeat(Animation animation) { //To change body of implemented methods use File | Settings | File Templates. } }); item.ani.setFillAfter(true); item.widget.startAnimation(item.ani); } }