List of usage examples for android.view.animation AccelerateInterpolator AccelerateInterpolator
public AccelerateInterpolator()
From source file:com.telenav.nodeflow.NodeFlowLayout.java
/** * perform alpha animation associated with closing or opening a node * * @param startIndex start index of child views to be animated * @param endIndex end index of child views to be animated * @param destAlpha final alpha of child views to be animated *//*from w w w . ja v a 2s.co m*/ private void animateDrillAlpha(final int startIndex, final int endIndex, final int destAlpha) { ValueAnimator animator = ValueAnimator.ofFloat(1 - destAlpha, destAlpha); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { for (int i = startIndex; i < endIndex; ++i) { getChildAt(i).setAlpha(((Float) animation.getAnimatedValue())); } } }); animator.addListener(new CustomAnimationListener() { @Override public void onAnimationStart(Animator animator) { for (int i = startIndex; i < getChildCount(); ++i) { getChildAt(i).setAlpha(1 - destAlpha); } } }); animator.setDuration(duration); if (destAlpha == 1) animator.setInterpolator(new AccelerateInterpolator()); else animator.setInterpolator(new DecelerateInterpolator(2)); animator.start(); }
From source file:com.glabs.homegenie.StartActivity.java
public void showLogo() { _islogovisible = true;//from w ww . j av a 2s .c o m runOnUiThread(new Runnable() { @Override public void run() { Animation fadeIn = new AlphaAnimation(0, 0.8f); fadeIn.setInterpolator(new AccelerateInterpolator()); //and this fadeIn.setStartOffset(0); fadeIn.setDuration(500); // AnimationSet animation = new AnimationSet(false); //change to false animation.addAnimation(fadeIn); animation.setFillAfter(true); RelativeLayout ivlogo = (RelativeLayout) findViewById(R.id.logo); ivlogo.startAnimation(animation); } }); }
From source file:com.taobao.weex.dom.action.AnimationAction.java
private @Nullable Interpolator createTimeInterpolator() { String interpolator = mAnimationBean.timingFunction; if (!TextUtils.isEmpty(interpolator)) { switch (interpolator) { case WXAnimationBean.EASE_IN: return new AccelerateInterpolator(); case WXAnimationBean.EASE_OUT: return new DecelerateInterpolator(); case WXAnimationBean.EASE_IN_OUT: return new AccelerateDecelerateInterpolator(); case WXAnimationBean.LINEAR: return new LinearInterpolator(); default:// www .ja va 2s . co m //Parse cubic-bezier try { SingleFunctionParser<Float> parser = new SingleFunctionParser<>(mAnimationBean.timingFunction, new SingleFunctionParser.FlatMapper<Float>() { @Override public Float map(String raw) { return Float.parseFloat(raw); } }); List<Float> params = parser.parse(WXAnimationBean.CUBIC_BEZIER); if (params != null && params.size() == WXAnimationBean.NUM_CUBIC_PARAM) { return PathInterpolatorCompat.create(params.get(0), params.get(1), params.get(2), params.get(3)); } else { return null; } } catch (RuntimeException e) { return null; } } } return null; }
From source file:com.jxlc.tajiproject.ui.MainActivity.java
private ScreenShotable replaceFragment(ScreenShotable screenShotable, int topPosition, String name) { // make Animation View view = findViewById(R.id.content_frame); int finalRadius = Math.max(view.getWidth(), view.getHeight()); SupportAnimator animator = ViewAnimationUtils.createCircularReveal(view, 0, topPosition, 0, finalRadius); animator.setInterpolator(new AccelerateInterpolator()); animator.setDuration(ViewAnimator.CIRCULAR_REVEAL_ANIMATION_DURATION); findViewById(R.id.content_overlay)//from w ww . j a v a 2s . co m .setBackground(new BitmapDrawable(getResources(), screenShotable.getBitmap())); animator.start(); // switch layout curLayout = name; getSupportActionBar().setTitle(PAGENAME_MAP.get(name)); ContentFragment newFragment = ContentFragment.newInstance(name); if (name.equals(TOWERCRANE) || name.equals(CONSTRUCTIONSITE)) { mUnityPlayer = new UnityPlayer(this); newFragment.setUnityPlayer(mUnityPlayer); } getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, newFragment).commit(); return newFragment; }
From source file:com.zhihu.android.app.mirror.app.MainActivity.java
@Override public void onDragDismiss(final ArtboardView view, boolean isDragDown) { mIsDragDismiss = true;/*from www . ja va 2 s . co m*/ switchToArtboardListView(); view.animate().alpha(0.0F).translationY(isDragDown ? -view.getHeight() : view.getHeight()) .setDuration(AnimUtils.DURATION).setInterpolator(new AccelerateInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { mIsDragDismiss = false; mArtboardPagerView.getBackground().mutate().setAlpha(255); view.setTranslationY(0.0F); view.setAlpha(1.0F); } }).start(); }
From source file:com.watasan.infospider.fragment.PrimitiveFragment.java
/** SCRIPT ACTION AREA --------------------------------------------------> */ public void testAnimation(float destX, float destY) { this.mDestX = Factory.getAdjustedX(destX); this.mDestY = Factory.getAdjustedY(destY); // SELECT LAYER FrameLayout relate = (FrameLayout) mRootView.findViewById(R.id.FLBackLayer); // ScrollView relate = (ScrollView)mRootView.findViewById(R.id.content); // relate.setVisibility(View.VISIBLE); AnimationSet set = new AnimationSet(true); set.setAnimationListener(this); TranslateAnimation translate;/*from w w w . j a v a 2 s.c om*/ float toX = this.mDestX; float fromX = this.mSrcX; float toY = this.mDestY; float fromY = this.mSrcY; translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX, Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY); translate.setDuration(Constants.Animation.IPF_START); translate.setInterpolator(new AccelerateInterpolator()); set.addAnimation(translate); set.setFillBefore(true); // set.setFillBefore(false); // set.setFillAfter(false); set.setFillAfter(true); relate.startAnimation(set); }
From source file:com.aniruddhc.acemusic.player.Drawers.QueueDrawerFragment.java
/** * Animates the play button to a pause button. *///from w ww.ja v a 2 s . c om private void animatePlayToPause() { //Check to make sure the current icon is the play icon. if (mPlayPauseButton.getId() != R.drawable.play_light) return; //Fade out the play button. final ScaleAnimation scaleOut = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2); scaleOut.setDuration(150); scaleOut.setInterpolator(new AccelerateInterpolator()); //Scale in the pause button. final ScaleAnimation scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2); scaleIn.setDuration(150); scaleIn.setInterpolator(new DecelerateInterpolator()); scaleOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mPlayPauseButton.setImageResource(R.drawable.pause_light); mPlayPauseButton.setPadding(0, 0, 0, 0); mPlayPauseButton.startAnimation(scaleIn); } @Override public void onAnimationRepeat(Animation animation) { } }); scaleIn.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mPlayPauseButton.setScaleX(1.0f); mPlayPauseButton.setScaleY(1.0f); mPlayPauseButton.setId(R.drawable.pause_light); } @Override public void onAnimationRepeat(Animation animation) { } }); mPlayPauseButton.startAnimation(scaleOut); }
From source file:com.arlib.floatingsearchview.util.view.MenuView.java
/** * Hides all the menu items flagged with "ifRoom" * * @param withAnim//from ww w .ja v a 2 s . co m */ public void hideIfRoomItems(boolean withAnim) { if (mMenu == -1) return; mActionShowAlwaysItems.clear(); cancelChildAnimListAndClear(); List<MenuItemImpl> showAlwaysActionItems = filter(mMenuItems, new MenuItemImplPredicate() { @Override public boolean apply(MenuItemImpl menuItem) { return menuItem.requiresActionButton(); } }); int actionItemIndex; for (actionItemIndex = 0; actionItemIndex < mActionItems.size() && actionItemIndex < showAlwaysActionItems.size(); actionItemIndex++) { final MenuItemImpl actionItem = showAlwaysActionItems.get(actionItemIndex); if (mActionItems.get(actionItemIndex).getItemId() != showAlwaysActionItems.get(actionItemIndex) .getItemId()) { ImageView action = (ImageView) getChildAt(actionItemIndex); action.setImageDrawable(Util.setIconColor(actionItem.getIcon(), mActionIconColor)); action.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mMenuCallback != null) mMenuCallback.onMenuItemSelected(mMenuBuilder, actionItem); } }); } mActionShowAlwaysItems.add(actionItem); } final int diff = mActionItems.size() - actionItemIndex + (mHasOverflow ? 1 : 0); anims = new ArrayList<>(); for (int i = 0; i < actionItemIndex; i++) { final View currentChild = getChildAt(i); final float destTransX = ACTION_DIMENSION_PX * diff - (mHasOverflow ? Util.dpToPx(8) : 0); anims.add(ViewPropertyObjectAnimator.animate(currentChild) .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0) .setInterpolator(new AccelerateInterpolator()).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentChild.setTranslationX(destTransX); } }).translationXBy(destTransX).get()); } for (int i = actionItemIndex; i < diff + actionItemIndex; i++) { final View currentView = getChildAt(i); currentView.setClickable(false); if (i != getChildCount() - 1) anims.add(ViewPropertyObjectAnimator.animate(currentView) .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0) .addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setTranslationX(ACTION_DIMENSION_PX); } }).translationXBy(ACTION_DIMENSION_PX).get()); anims.add(ViewPropertyObjectAnimator.animate(currentView) .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0) .addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setScaleX(0.5f); } }).scaleX(.5f).get()); anims.add(ViewPropertyObjectAnimator.animate(currentView) .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0) .addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setScaleY(0.5f); } }).scaleY(.5f).get()); anims.add(ViewPropertyObjectAnimator.animate(getChildAt(i)) .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0) .addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setAlpha(0.0f); } }).alpha(0.0f).get()); } final int actinItemsCount = actionItemIndex; if (!anims.isEmpty()) { AnimatorSet animSet = new AnimatorSet(); if (!withAnim) animSet.setDuration(0); animSet.playTogether(anims.toArray(new ObjectAnimator[anims.size()])); animSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mOnVisibleWidthChanged != null) mOnVisibleWidthChanged.onVisibleWidthChanged(((int) ACTION_DIMENSION_PX * actinItemsCount)); } }); animSet.start(); } }
From source file:co.dift.ui.SwipeToAction.java
private void swipeRight() { if (frontView == null) { return;/* w ww .j av a 2s . com*/ } final View animated = touchedView; frontView.animate().setDuration(SWIPE_ANIMATION_DURATION).setInterpolator(new AccelerateInterpolator()) .setListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { runningAnimationsOn.add(animated); } @Override public void onAnimationEnd(Animator animation) { runningAnimationsOn.remove(animated); if (swipeListener.swipeRight(touchedViewHolder.getItemData())) { resetPosition(); } else { checkQueue(); } } @Override public void onAnimationCancel(Animator animation) { runningAnimationsOn.remove(animated); } @Override public void onAnimationRepeat(Animator animation) { runningAnimationsOn.add(animated); } }).x(frontViewX + frontViewW); }
From source file:com.ruesga.rview.widget.ActivityStatsChart.java
private void animateChart() { // Animate the chart if (mAnimator != null && mAnimator.isRunning()) { mAnimator.cancel();/* ww w. ja v a 2 s . c om*/ } mAnimationDelta = 0f; mAnimator = ValueAnimator.ofFloat(0f, 1f); mAnimator.setInterpolator(new AccelerateInterpolator()); mAnimator.setDuration(350L); mAnimator.addUpdateListener(animation -> { mAnimationDelta = animation.getAnimatedFraction(); computeDrawObjects(); ViewCompat.postInvalidateOnAnimation(this); }); mAnimator.start(); }