List of usage examples for android.view.animation DecelerateInterpolator DecelerateInterpolator
public DecelerateInterpolator(float factor)
From source file:com.example.piechart3d.PieChart3DView.java
@SuppressLint("NewApi") public void animateV(float velocity) { Log.d("appOnF", "Cancle"); if (mZAnimator != null) mZAnimator.cancel();/*from w w w .ja va2 s . c om*/ mZAnimator = ObjectAnimator.ofFloat(mRenderer, "angle_z", mRenderer.angle_z + (60 * velocity)); mZAnimator.setDuration(2000); mZAnimator.addListener(new AnimatorListener() { @Override public void onAnimationCancel(final Animator animation) { } @Override public void onAnimationEnd(final Animator animation) { // progressBar.setProgress(progress); } @Override public void onAnimationRepeat(final Animator animation) { } @Override public void onAnimationStart(final Animator animation) { } }); // mProgressBarAnimator.reverse(); mZAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator animation) { } }); DecelerateInterpolator di = new DecelerateInterpolator(1.0f); mZAnimator.setInterpolator(di); mZAnimator.start(); }
From source file:com.android.leanlauncher.Workspace.java
private void animateBackgroundGradient(float finalAlpha, boolean animated) { final DragLayer dragLayer = mLauncher.getDragLayer(); if (mBackgroundFadeInAnimation != null) { mBackgroundFadeInAnimation.cancel(); mBackgroundFadeInAnimation = null; }/*w ww .j av a2s. com*/ 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()); } }); mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION); mBackgroundFadeOutAnimation.start(); } else { dragLayer.setBackgroundAlpha(finalAlpha); } } }
From source file:com.yekertech.tvbarsetting.dialog.DialogFragment.java
private void performEntryTransition() { final View dialogView = getView(); final View contentView = (View) dialogView.getTag(R.id.content_fragment); final View actionContainerView = dialogView.findViewById(R.id.action_fragment); mIntroAnimationInProgress = true;/*from ww w .ja v a 2s . c o m*/ // Fade out the old activity. getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out); int bgColor = contentView.getContext().getResources().getColor(R.color.lb_dialog_activity_background); final ColorDrawable bgDrawable = new ColorDrawable(); bgDrawable.setColor(bgColor); bgDrawable.setAlpha(0); dialogView.setBackground(bgDrawable); dialogView.setVisibility(View.INVISIBLE); runDelayedAnim(new Runnable() { @Override public void run() { if (!isAdded()) { // We have been detached before this could run, // so just bail return; } dialogView.setVisibility(View.VISIBLE); // Fade in the activity background protection ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255); oa.setDuration(ANIMATE_IN_DURATION); oa.setStartDelay(SECONDARY_ANIMATE_DELAY); oa.setInterpolator(new DecelerateInterpolator(1.0f)); oa.start(); boolean isRtl = ViewCompat.getLayoutDirection(contentView) == ViewCompat.LAYOUT_DIRECTION_RTL; int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE; int endDist = isRtl ? -actionContainerView.getMeasuredWidth() : actionContainerView.getMeasuredWidth(); // Fade in and slide in the ContentFragment // TextViews from the start. prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false); // Fade in and slide in the ActionFragment from the // end. prepareAndAnimateView(actionContainerView, endDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true); // Fade in the selector. if (mSelectorAnimator != null) { mSelectorAnimator.fadeIn(); } } }); }
From source file:com.android.tv.settings.dialog.DialogFragment.java
private void performEntryTransition() { final View dialogView = getView(); final View contentView = (View) dialogView.getTag(R.id.content_fragment); final View actionContainerView = dialogView.findViewById(R.id.action_fragment); mIntroAnimationInProgress = true;//from www .j ava 2 s. c o m // Fade out the old activity. getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out); int bgColor = contentView.getContext().getResources().getColor(R.color.lb_dialog_activity_background); final ColorDrawable bgDrawable = new ColorDrawable(); bgDrawable.setColor(bgColor); bgDrawable.setAlpha(0); dialogView.setBackground(bgDrawable); dialogView.setVisibility(View.INVISIBLE); runDelayedAnim(new Runnable() { @Override public void run() { if (!isAdded()) { // We have been detached before this could run, // so just bail return; } dialogView.setVisibility(View.VISIBLE); // Fade in the activity background protection ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255); oa.setDuration(ANIMATE_IN_DURATION); oa.setStartDelay(SECONDARY_ANIMATE_DELAY); oa.setInterpolator(new DecelerateInterpolator(1.0f)); oa.start(); boolean isRtl = ViewCompat.getLayoutDirection(contentView) == View.LAYOUT_DIRECTION_RTL; int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE; int endDist = isRtl ? -actionContainerView.getMeasuredWidth() : actionContainerView.getMeasuredWidth(); // Fade in and slide in the ContentFragment // TextViews from the start. prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false); // Fade in and slide in the ActionFragment from the // end. prepareAndAnimateView(actionContainerView, endDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true); // Fade in the selector. if (mSelectorAnimator != null) { mSelectorAnimator.fadeIn(); } } }); }
From source file:cw.kop.autobackground.sources.SourceListFragment.java
/** * Shows LocalImageFragment to view images * * @param view source card which was selected * @param index position of source in listAdapter *///from w w w . j ava 2s .com private void showViewImageFragment(final View view, final int index) { sourceList.setOnItemClickListener(null); sourceList.setEnabled(false); listAdapter.saveData(); Source item = listAdapter.getItem(index); String type = item.getType(); String directory; if (type.equals(AppSettings.FOLDER)) { directory = item.getData().split(AppSettings.DATA_SPLITTER)[0]; } else { directory = AppSettings.getDownloadPath() + "/" + item.getTitle() + " " + AppSettings.getImagePrefix(); } Log.i(TAG, "Directory: " + directory); final RelativeLayout sourceContainer = (RelativeLayout) view.findViewById(R.id.source_container); final ImageView sourceImage = (ImageView) view.findViewById(R.id.source_image); final View imageOverlay = view.findViewById(R.id.source_image_overlay); final EditText sourceTitle = (EditText) view.findViewById(R.id.source_title); final ImageView deleteButton = (ImageView) view.findViewById(R.id.source_delete_button); final ImageView viewButton = (ImageView) view.findViewById(R.id.source_view_image_button); final ImageView editButton = (ImageView) view.findViewById(R.id.source_edit_button); final LinearLayout sourceExpandContainer = (LinearLayout) view.findViewById(R.id.source_expand_container); final float viewStartHeight = sourceContainer.getHeight(); final float viewStartY = view.getY(); final float overlayStartAlpha = imageOverlay.getAlpha(); final float listHeight = sourceList.getHeight(); Log.i(TAG, "listHeight: " + listHeight); Log.i(TAG, "viewStartHeight: " + viewStartHeight); final LocalImageFragment localImageFragment = new LocalImageFragment(); Bundle arguments = new Bundle(); arguments.putString("view_path", directory); localImageFragment.setArguments(arguments); Animation animation = new Animation() { private boolean needsFragment = true; @Override protected void applyTransformation(float interpolatedTime, Transformation t) { if (needsFragment && interpolatedTime >= 1) { needsFragment = false; getFragmentManager().beginTransaction() .add(R.id.content_frame, localImageFragment, "image_fragment").addToBackStack(null) .setTransition(FragmentTransaction.TRANSIT_NONE).commit(); } ViewGroup.LayoutParams params = sourceContainer.getLayoutParams(); params.height = (int) (viewStartHeight + (listHeight - viewStartHeight) * interpolatedTime); sourceContainer.setLayoutParams(params); view.setY(viewStartY - interpolatedTime * viewStartY); deleteButton.setAlpha(1.0f - interpolatedTime); viewButton.setAlpha(1.0f - interpolatedTime); editButton.setAlpha(1.0f - interpolatedTime); sourceTitle.setAlpha(1.0f - interpolatedTime); imageOverlay.setAlpha(overlayStartAlpha - overlayStartAlpha * (1.0f - interpolatedTime)); sourceExpandContainer.setAlpha(1.0f - interpolatedTime); } @Override public boolean willChangeBounds() { return true; } }; animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (needsListReset) { Parcelable state = sourceList.onSaveInstanceState(); sourceList.setAdapter(null); sourceList.setAdapter(listAdapter); sourceList.onRestoreInstanceState(state); sourceList.setOnItemClickListener(SourceListFragment.this); sourceList.setEnabled(true); needsListReset = false; } } @Override public void onAnimationRepeat(Animation animation) { } }); ValueAnimator cardColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), AppSettings.getDialogColor(appContext), getResources().getColor(AppSettings.getBackgroundColorResource())); cardColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { sourceContainer.setBackgroundColor((Integer) animation.getAnimatedValue()); } }); DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator(1.5f); animation.setDuration(INFO_ANIMATION_TIME); cardColorAnimation.setDuration(INFO_ANIMATION_TIME); animation.setInterpolator(decelerateInterpolator); cardColorAnimation.setInterpolator(decelerateInterpolator); needsListReset = true; cardColorAnimation.start(); view.startAnimation(animation); }
From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java
private void performEntryTransition() { final View dialogView = getView(); final View contentView = (View) dialogView.getTag(R.id.content_fragment); final View actionContainerView = dialogView.findViewById(R.id.action_fragment); mIntroAnimationInProgress = true;/*from w w w. j ava 2s . co m*/ // Fade out the old activity. getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out); int bgColor = contentView.getContext().getResources().getColor(R.color.lb_dialog_activity_background); final ColorDrawable bgDrawable = new ColorDrawable(); bgDrawable.setColor(bgColor); bgDrawable.setAlpha(0); dialogView.setBackground(bgDrawable); dialogView.setVisibility(View.INVISIBLE); // We need to defer the remainder of the animation preparation until the first layout has // occurred, as we don't yet know the final location of the icon. contentView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { contentView.getViewTreeObserver().removeOnGlobalLayoutListener(this); // if we buildLayer() at this time, the texture is // actually not created delay a little so we can make // sure all hardware layer is created before animation, // in that way we can avoid the jittering of start // animation contentView.postOnAnimationDelayed(mEntryAnimationRunnable, mAnimateDelay); } Runnable mEntryAnimationRunnable = new Runnable() { @Override public void run() { if (!isAdded()) { // We have been detached before this could run, so just bail. return; } dialogView.setVisibility(View.VISIBLE); // Fade in the activity background protection ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255); oa.setDuration(mAnimateInDuration); oa.setStartDelay(mSecondaryAnimateDelay); oa.setInterpolator(new DecelerateInterpolator(1.0f)); oa.start(); boolean isRtl = ViewCompat.getLayoutDirection(contentView) == View.LAYOUT_DIRECTION_RTL; int startDist = isRtl ? mSlideInDistance : -mSlideInDistance; int endDist = isRtl ? -actionContainerView.getMeasuredWidth() : actionContainerView.getMeasuredWidth(); // Fade in and slide in the ContentFragment TextViews from the start. prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false); // Fade in and slide in the ActionFragment from the end. prepareAndAnimateView(actionContainerView, endDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true); } }; }); }
From source file:com.yekertech.tvbarsetting.dialog.SettingsLayoutFragment.java
private void performEntryTransition() { final View dialogView = getView(); final View contentView = (View) dialogView.getTag(R.id.content_fragment); final View actionContainerView = dialogView.findViewById(R.id.action_fragment); mIntroAnimationInProgress = true;//from w w w.ja va2s. c o m // Fade out the old activity. getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out); int bgColor = contentView.getContext().getColor(R.color.lb_dialog_activity_background); final ColorDrawable bgDrawable = new ColorDrawable(); bgDrawable.setColor(bgColor); bgDrawable.setAlpha(0); dialogView.setBackground(bgDrawable); dialogView.setVisibility(View.INVISIBLE); // We need to defer the remainder of the animation preparation until the first layout has // occurred, as we don't yet know the final location of the icon. contentView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { contentView.getViewTreeObserver().removeOnGlobalLayoutListener(this); // if we buildLayer() at this time, the texture is // actually not created delay a little so we can make // sure all hardware layer is created before animation, // in that way we can avoid the jittering of start // animation contentView.postOnAnimationDelayed(mEntryAnimationRunnable, mAnimateDelay); } final Runnable mEntryAnimationRunnable = new Runnable() { @Override public void run() { if (!isAdded()) { // We have been detached before this could run, so just bail. return; } dialogView.setVisibility(View.VISIBLE); // Fade in the activity background protection ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255); oa.setDuration(mAnimateInDuration); oa.setStartDelay(mSecondaryAnimateDelay); oa.setInterpolator(new DecelerateInterpolator(1.0f)); oa.start(); boolean isRtl = ViewCompat.getLayoutDirection(contentView) == ViewCompat.LAYOUT_DIRECTION_RTL; int startDist = isRtl ? mSlideInDistance : -mSlideInDistance; int endDist = isRtl ? -actionContainerView.getMeasuredWidth() : actionContainerView.getMeasuredWidth(); // Fade in and slide in the ContentFragment TextViews from the start. prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false); // Fade in and slide in the ActionFragment from the end. prepareAndAnimateView(actionContainerView, endDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true); } }; }); }
From source file:com.android.tv.settings.dialog.DialogFragment.java
private void prepareAndAnimateView(final View v, float initTransX, final boolean notifyAnimationFinished) { v.setLayerType(View.LAYER_TYPE_HARDWARE, null); v.buildLayer();// www . j a v a 2 s .co m v.setAlpha(0); v.setTranslationX(initTransX); v.animate().alpha(1f).translationX(0).setDuration(ANIMATE_IN_DURATION) .setStartDelay(SECONDARY_ANIMATE_DELAY); v.animate().setInterpolator(new DecelerateInterpolator(1.0f)); v.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { v.setLayerType(View.LAYER_TYPE_NONE, null); if (notifyAnimationFinished) { onIntroAnimationFinished(); } } }); v.animate().start(); }
From source file:com.goka.flickableview.ImageViewTouchBase.java
protected void zoomTo(float scale, float centerX, float centerY, final long durationMs) { if (scale > getMaxScale()) { scale = getMaxScale();//w w w . ja v a2s. c o m } final float oldScale = getScale(); Matrix m = new Matrix(mSuppMatrix); m.postScale(scale, scale, centerX, centerY); RectF rect = getCenter(m, true, true); final float finalScale = scale; final float destX = centerX + rect.left * scale; final float destY = centerY + rect.top * scale; stopAllAnimations(); ValueAnimatorCompat animatorCompat = AnimatorCompatHelper.emptyValueAnimator(); animatorCompat.setDuration(durationMs); final Interpolator interpolator = new DecelerateInterpolator(1.0f); animatorCompat.addUpdateListener(new AnimatorUpdateListenerCompat() { @Override public void onAnimationUpdate(ValueAnimatorCompat animation) { float fraction = interpolator.getInterpolation(animation.getAnimatedFraction()); float value = oldScale + (fraction * (finalScale - oldScale)); zoomTo(value, destX, destY); } }); animatorCompat.start(); }
From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java
private void prepareAndAnimateView(final View v, float initTransX, final boolean notifyAnimationFinished) { v.setLayerType(View.LAYER_TYPE_HARDWARE, null); v.buildLayer();//from ww w. ja v a 2 s. c o m v.setAlpha(0); v.setTranslationX(initTransX); v.animate().alpha(1f).translationX(0).setDuration(mAnimateInDuration).setStartDelay(mSecondaryAnimateDelay); v.animate().setInterpolator(new DecelerateInterpolator(1.0f)); v.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { v.setLayerType(View.LAYER_TYPE_NONE, null); if (notifyAnimationFinished) { onIntroAnimationFinished(); } } }); v.animate().start(); }