List of usage examples for android.view.animation DecelerateInterpolator DecelerateInterpolator
public DecelerateInterpolator()
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:// ww w .j ava 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.aniruddhc.acemusic.player.Drawers.QueueDrawerFragment.java
/** * Animates the play button to a pause button. *//*from w ww. jav a 2 s . co m*/ 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.example.kuassivi.material_avatar.feature.ChooseAvatarActivity.java
/** * This method will not fire on devices prior to LOLLIPOP *///from w w w. j ava 2 s . c o m @TargetApi(Build.VERSION_CODES.LOLLIPOP) private void initTransitions() { // Perform some visibility strategies on the header and shared views getWindow().getSharedElementEnterTransition().addListener(new TransitionListenerAdapter() { @Override public void onTransitionStart(Transition transition) { mHeaderView.setVisibility(View.INVISIBLE); } @Override public void onTransitionEnd(Transition transition) { mHeaderView.setVisibility(View.VISIBLE); mSharedAvatarView.setAlpha(0f); } }); // Setup the return transition getWindow().getReturnTransition().addListener(new TransitionListenerAdapter() { @Override public void onTransitionStart(Transition transition) { final long duration = getResources().getInteger(R.integer.duration_fast); if (mAvatarUrl != null) { int dWidth = mAvatarContainer.getDrawableWidth(), dHeight = mAvatarContainer.getDrawableHeight(), vWidth = mAvatarContainer.getInsetWidth(), vHeight = mAvatarContainer.getInsetHeight(); float scaleTo = (float) sharedAvatarSize / (float) vHeight; long delay = Float .valueOf((float) duration / (((float) vWidth / (float) vHeight) + ((float) dWidth / (float) dHeight))) .longValue(); ScalableBitmapAnimator bitmapAnimator = new ScalableBitmapAnimator(scaleTo, ScalableBitmapAnimator.SCALE_TO); bitmapAnimator.setScaleFactor(1f).setInterpolator(new DecelerateInterpolator()) .setDuration(duration).setStartDelay(delay); mAvatarContainer.setBitmapAnimators(bitmapAnimator).startBitmapAnimation(); } new Handler().postDelayed(new Runnable() { @Override public void run() { if (mSharedAvatarView != null && !isFinishing()) { mSharedAvatarView.setAlpha(1f); } } }, duration); } }); }
From source file:com.github.jokar.rxupload.widget.ProgressDownloadView.java
public void setPercentage(float newProgress) { if (newProgress < 0 || newProgress > 100) { throw new IllegalArgumentException("setPercentage not between 0 and 100"); }/*from w w w. j a v a2 s .co m*/ mState = State.STATE_WORKING; mTarget = newProgress; ObjectAnimator anim = ObjectAnimator.ofFloat(this, "progress", getProgress(), mTarget); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration((long) (ANIMATION_DURATION_BASE + Math.abs(mTarget * 10 - getProgress() * 10) / 2)); anim.start(); }
From source file:com.fa.imaged.activity.DetailActivityV2.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mApp = new InstagramApp(getBaseContext(), ApplicationData.CLIENT_ID, ApplicationData.CLIENT_SECRET, ApplicationData.CALLBACK_URL); // Get Theme Info SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); selectedTheme = prefs.getString("theme_color", "0"); selectedThemeInt = Integer.parseInt(selectedTheme); themePrimaryColors = getResources().getStringArray(R.array.themeColorsPrimary); themePrimaryDarkColors = getResources().getStringArray(R.array.themeColorsPrimaryDark); headerHeight = getResources().getDimensionPixelSize(R.dimen.action_bar_max_height); minHeaderHeight = getResources().getDimensionPixelSize(R.dimen.action_bar_height); toolbarTitleLeftMargin = getResources().getDimensionPixelSize(R.dimen.toolbar_left_margin); detailImageLoaderv2 = (InstagramImage) getIntent().getSerializableExtra("EXTRA_DATA"); detailVideoV2 = (VideoView) findViewById(R.id.post_video); detailImageV2 = (ImageView) findViewById(R.id.post_image); ViewCompat.setTransitionName(detailImageV2, EXTRA_IMAGE); ViewCompat.setTransitionName(detailVideoV2, EXTRA_IMAGE); detailScrollView = (ObservableScrollView) findViewById(R.id.detail_scrollview); detailUserInfo = (RelativeLayout) findViewById(R.id.detail_userinfo); detailShare = (LinearLayout) findViewById(R.id.detail_share); detailComments = (LinearLayout) findViewById(R.id.detail_comments); detailLike = (LinearLayout) findViewById(R.id.detail_like); detailFullName = (TextView) findViewById(R.id.detail_fullname); detailUserName = (TextView) findViewById(R.id.detail_username); detailDate = (TextView) findViewById(R.id.detail_date); detailCaption = (TextView) findViewById(R.id.detail_postcaption); detailLikeStatus = (ImageView) findViewById(R.id.detail_likeStatus); detailLikeCounts = (TextView) findViewById(R.id.detail_likeCounts); detailCommentCounts = (TextView) findViewById(R.id.detail_commentCounts); detailProfilePic = (ImageView) findViewById(R.id.detail_user_pic); detailvBgLike = (View) findViewById(R.id.vBgLike); detailivLike = (ImageView) findViewById(R.id.ivLike); Picasso.with(this).load(detailImageLoaderv2.profile_picture).transform(new PicassoRound()) .into(detailProfilePic);// ww w . j a v a 2 s. c o m detailFullName.setText(detailImageLoaderv2.full_name); detailUserName.setText(detailImageLoaderv2.username + ", "); detailDate.setText(detailImageLoaderv2.taken_at); if (detailImageLoaderv2.user_has_liked) { Drawable myIcon = getResources().getDrawable(R.drawable.ic_like); myIcon.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP); detailLikeStatus.setImageDrawable(myIcon); } if (detailImageLoaderv2.caption != null) { detailCaption.setText(detailImageLoaderv2.caption); } else { detailCaption.setVisibility(View.GONE); } detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count)); detailCommentCounts.setText(String.valueOf(detailImageLoaderv2.comment_count)); detailImageV2.setOnTouchListener(new OnTouchListener() { private GestureDetector gestureDetector = new GestureDetector(DetailActivityV2.this, new GestureDetector.SimpleOnGestureListener() { boolean isTouchFirst = true; @Override public boolean onDoubleTap(MotionEvent eV) { animatePhotoLike(); if (!detailImageLoaderv2.user_has_liked) { HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, true, 0); liker.execute(); try { detailImageLoaderv2 = liker.get(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (detailImageLoaderv2.user_has_liked) { Drawable myIcon = getResources().getDrawable(R.drawable.ic_like); myIcon.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP); detailLikeStatus.setImageDrawable(myIcon); } detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count)); } return super.onDoubleTap(eV); } // implement here other callback methods like onFling, onScroll as necessary @Override public boolean onSingleTapConfirmed(MotionEvent e) { if (isTouchFirst) { isTouchFirst = false; getToolbar().animate().translationY(-getToolbar().getBottom()).alpha(0) .setDuration(320).setInterpolator(new DecelerateInterpolator()); } else { isTouchFirst = true; getToolbar().animate().translationY(0).alpha(1).setDuration(400) .setInterpolator(new DecelerateInterpolator()); //mSystemUiHider.show(); Log.d("Here isTouch is false", ">"); } return true; } }); @Override public boolean onTouch(View v, MotionEvent event) { gestureDetector.onTouchEvent(event); return true; } }); detailShare.setOnClickListener(this); detailLike.setOnClickListener(this); detailProfilePic.setOnClickListener(this); detailScrollView.getViewTreeObserver() .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { int scroll = detailScrollView.getScrollY(); saveInitialScroll(scroll); /* if(detailUserInfo != null){ if (getAlpha(-scroll - getToolbar().getHeight()) >= 1.0f) { detailUserInfo.setTranslationY(-detailUserInfo.getHeight() + getToolbar().getHeight()); } else { detailUserInfo.setTranslationY(-scroll - detailUserInfo.getHeight()); } } */ findViewById(R.id.detail_image_container) .setTranslationY(Math.max(0, detailScrollView.getScrollY() + minHeaderTranslation)); float offset = 1 - Math.max((float) (-minHeaderTranslation - detailScrollView.getScrollY()) / -minHeaderTranslation, 0f); // Now that we have this ratio, we only have to apply translations, scales, // alpha, etc. to the header views // For instance, this will move the toolbar title & subtitle on the X axis // from its original position when the ListView will be completely scrolled // down, to the Toolbar title position when it will be scrolled up. //detailFullName.setTranslationX(toolbarTitleLeftMargin * offset); //detailUserName.setTranslationX(toolbarTitleLeftMargin * offset); //detailProfilePic.animate().alpha(1.0f * offset).translationX(-toolbarTitleLeftMargin * offset); } }); commentsAdapter = new CommentsAdapter(this, detailImageLoaderv2.comment_list); if (detailImageLoaderv2.comment_count > 8) { Button load_more_button = new Button(this); load_more_button.setText(getResources().getString(R.string.load_old_comments)); load_more_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(), getResources().getString(R.string.coming_soon), Toast.LENGTH_SHORT).show(); } }); detailComments.addView(load_more_button, 0); } for (int i = 0; i < commentsAdapter.getCount(); i++) { View item = commentsAdapter.getView(i, null, detailComments); detailComments.addView(item); } }
From source file:com.shalzz.attendance.activity.MainActivity.java
public void setDrawerAsUp(boolean enabled) { if (mDrawerLayout == null) return;/*from w w w . j a v a 2 s . co m*/ float start = enabled ? 0f : 1f; float end = enabled ? 1f : 0f; mDrawerLayout.setDrawerLockMode( enabled ? DrawerLayout.LOCK_MODE_LOCKED_CLOSED : DrawerLayout.LOCK_MODE_UNLOCKED); ValueAnimator anim = ValueAnimator.ofFloat(start, end); anim.addUpdateListener(valueAnimator -> { float slideOffset = (Float) valueAnimator.getAnimatedValue(); mDrawerToggle.onDrawerSlide(mDrawerLayout, slideOffset); }); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration(300); anim.start(); }
From source file:com.appolica.interactiveinfowindow.InfoWindowManager.java
private void animateWindowOpen(@NonNull final InfoWindow infoWindow, @NonNull final View container) { final SimpleAnimationListener animationListener = new SimpleAnimationListener() { @Override// w ww . j av a2 s . com public void onAnimationStart(Animation animation) { container.setVisibility(View.VISIBLE); propagateShowEvent(infoWindow, InfoWindow.State.SHOWING); } @Override public void onAnimationEnd(Animation animation) { propagateShowEvent(infoWindow, InfoWindow.State.SHOWN); setCurrentWindow(infoWindow); } }; if (showAnimation == null) { container.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { final int containerWidth = container.getWidth(); final int containerHeight = container.getHeight(); final float pivotX = container.getX() + containerWidth / 2; final float pivotY = container.getY() + containerHeight; final ScaleAnimation scaleAnimation = new ScaleAnimation(0f, 1f, 0f, 1f, pivotX, pivotY); scaleAnimation.setDuration(DURATION_WINDOW_ANIMATION); scaleAnimation.setInterpolator(new DecelerateInterpolator()); scaleAnimation.setAnimationListener(animationListener); container.startAnimation(scaleAnimation); container.getViewTreeObserver().removeOnPreDrawListener(this); return true; } }); } else { showAnimation.setAnimationListener(animationListener); container.startAnimation(showAnimation); } }
From source file:com.mahhaus.scanloto.ScannerActivity.java
private void showErrorMessageUiAnimated(String message) { if (lastErrorRecieved == 0) { // the cleanup takes care of removing the message after some time if the error did not show up again handler.post(errorMessageCleanup); }// ww w . j a v a 2s.c o m lastErrorRecieved = System.currentTimeMillis(); if (errorMessageAnimator != null && (errorMessageAnimator.isRunning() || errorMessage.getText().equals(message))) { return; } errorMessageLayout.setVisibility(View.VISIBLE); errorMessage.setBackgroundColor(ContextCompat.getColor(this, R.color.anyline_blue_darker)); errorMessage.setAlpha(0f); errorMessage.setText(message); errorMessageAnimator = ObjectAnimator.ofFloat(errorMessage, "alpha", 0f, 1f); errorMessageAnimator.setDuration(getResources().getInteger(R.integer.error_message_delay)); errorMessageAnimator.setInterpolator(new DecelerateInterpolator()); errorMessageAnimator.start(); }
From source file:org.zywx.wbpalmstar.engine.EBrowserWidget.java
public void goMySpace(View view) { addView(view);//from www .j ava 2 s.c om TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f); anim.setDuration(250); DecelerateInterpolator di = new DecelerateInterpolator(); anim.setInterpolator(di); view.startAnimation(anim); mBroWindow.setVisibility(GONE); }
From source file:org.xbmc.kore.ui.generic.NavigationDrawerFragment.java
/** * Animates the drawerToggle from the hamburger to an arrow or vice versa * @param toArrow True, hamburger to arrow, false arrow to hamburger *//*from w w w .ja v a 2s . c o m*/ public void animateDrawerToggle(final boolean toArrow) { float start = toArrow ? 0.0f : 1.0f, end = 1.0f - start; ValueAnimator anim = ValueAnimator.ofFloat(start, end); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float slideOffset = (Float) valueAnimator.getAnimatedValue(); mDrawerToggle.onDrawerSlide(mDrawerLayout, slideOffset); } }); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration(500); anim.start(); }