List of usage examples for android.view.animation AccelerateDecelerateInterpolator AccelerateDecelerateInterpolator
public AccelerateDecelerateInterpolator()
From source file:com.dmallcott.progressfloatingactionbutton.ProgressView.java
public void setCurrentProgress(int currentProgress, boolean animate) { // If the view is animating no further actions are allowed if (isAnimating) return;/*from w ww .j a v a2 s . c o m*/ if (this.mTargetProgress >= mTotalProgress) this.mTargetProgress = mTotalProgress; else this.mTargetProgress = currentProgress; if (animate && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // Animations are only available from API 11 and forth ValueAnimator va = ValueAnimator.ofInt(mCurrentProgress, mTargetProgress); va.setInterpolator(new AccelerateDecelerateInterpolator()); va.setDuration(mAnimationDuration); va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onAnimationUpdate(ValueAnimator animation) { mCurrentProgress = (Integer) animation.getAnimatedValue(); ProgressView.this.invalidate(); } }); va.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { isAnimating = true; } @Override public void onAnimationEnd(Animator animation) { isAnimating = false; } @Override public void onAnimationCancel(Animator animation) { isAnimating = false; } @Override public void onAnimationRepeat(Animator animation) { isAnimating = true; } }); va.start(); } else { mCurrentProgress = mTargetProgress; invalidate(); } if (this.mTargetProgress == mTotalProgress) mListener.onProgressCompleted(); }
From source file:net.semantic_error.turritype.sample.TypeActivity.java
private List<TimeInterpolator> getDefaultInterpolatorList() { List<TimeInterpolator> interpolatorList = new ArrayList<>(); interpolatorList.add(new LinearInterpolator()); interpolatorList.add(new FastOutSlowInInterpolator()); interpolatorList.add(new AccelerateDecelerateInterpolator()); return interpolatorList; }
From source file:com.chromium.fontinstaller.util.ViewUtils.java
public static void reveal(Activity activity, View view, View sourceView, int colorRes) { if (activity == null || view == null || sourceView == null) return;/*from w ww .j av a 2 s . co m*/ if (isLollipop()) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) activity.getWindow().getDecorView() .getOverlay(); final Rect displayRect = new Rect(); view.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(activity); revealView.setTop(displayRect.top); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes)); groupOverlay.add(revealView); final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); try { final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_mediumAnimTime)); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_shortAnimTime)); alphaAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in)); view.setVisibility(View.VISIBLE); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); } }); animatorSet.start(); } catch (IllegalStateException e) { Timber.i("View is detached - not animating"); } } else { view.setVisibility(View.VISIBLE); } }
From source file:com.grottworkshop.gwscirclereveal.animation.ViewAnimationUtils.java
/** * Lifting view//w ww . j a v a 2 s. com * * @param view The animation target * @param baseRotation initial Rotation X in 3D space * @param fromY initial Y position of view * @param duration aniamtion duration * @param startDelay start delay before animation begin */ @Deprecated public static void liftingFromBottom(View view, float baseRotation, float fromY, int duration, int startDelay) { view.setRotationX(baseRotation); view.setTranslationY(fromY); animate(view).setInterpolator(new AccelerateDecelerateInterpolator()).setDuration(duration) .setStartDelay(startDelay).rotationX(0).translationY(0).start(); }
From source file:android.support.graphics.drawable.AnimationUtilsCompat.java
private static Interpolator createInterpolatorFromXml(Context context, Resources res, Theme theme, XmlPullParser parser) throws XmlPullParserException, IOException { Interpolator interpolator = null;/*from w w w .j a v a 2s. c om*/ // Make sure we are on a start tag. int type; int depth = parser.getDepth(); while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { if (type != XmlPullParser.START_TAG) { continue; } AttributeSet attrs = Xml.asAttributeSet(parser); String name = parser.getName(); if (name.equals("linearInterpolator")) { interpolator = new LinearInterpolator(); } else if (name.equals("accelerateInterpolator")) { interpolator = new AccelerateInterpolator(context, attrs); } else if (name.equals("decelerateInterpolator")) { interpolator = new DecelerateInterpolator(context, attrs); } else if (name.equals("accelerateDecelerateInterpolator")) { interpolator = new AccelerateDecelerateInterpolator(); } else if (name.equals("cycleInterpolator")) { interpolator = new CycleInterpolator(context, attrs); } else if (name.equals("anticipateInterpolator")) { interpolator = new AnticipateInterpolator(context, attrs); } else if (name.equals("overshootInterpolator")) { interpolator = new OvershootInterpolator(context, attrs); } else if (name.equals("anticipateOvershootInterpolator")) { interpolator = new AnticipateOvershootInterpolator(context, attrs); } else if (name.equals("bounceInterpolator")) { interpolator = new BounceInterpolator(); } else if (name.equals("pathInterpolator")) { interpolator = new PathInterpolatorCompat(context, attrs, parser); } else { throw new RuntimeException("Unknown interpolator name: " + parser.getName()); } } return interpolator; }
From source file:com.github.rubensousa.floatingtoolbar.FloatingAnimatorImpl.java
@Override public void hide() { super.hide(); // A snackbar might have appeared, so we need to update the fab position again if (getAppBar() != null) { getFab().setY(getFloatingToolbar().getY()); } else {/* w w w . j a va2 s . c o m*/ getFab().setTranslationY(getFloatingToolbar().getTranslationY()); } final int fabNewY = getFab().getTop(); ViewCompat.animate(getFab()).x(getFab().getLeft()).y(fabNewY) .translationY(getFloatingToolbar().getTranslationY()).scaleX(1f).scaleY(1f) .setStartDelay(FAB_UNMORPH_DELAY).setDuration(FAB_UNMORPH_DURATION) .setInterpolator(new AccelerateInterpolator()) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationStart(View view) { getFab().setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(View view) { // Make sure the fab goes to the right place after the animation ends // when the Appbar is attached if (getAppBar() != null && getFab().getVisibility() == View.INVISIBLE) { getFab().show(); } getAnimationListener().onAnimationFinished(); } }); ViewCompat.animate(getFloatingToolbar()).scaleX(0f).setDuration(CIRCULAR_UNREVEAL_DURATION) .setStartDelay(CIRCULAR_UNREVEAL_DELAY).setInterpolator(new AccelerateDecelerateInterpolator()) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationEnd(View view) { getFloatingToolbar().setVisibility(View.INVISIBLE); ViewCompat.animate(getFloatingToolbar()).setListener(null); } }); }
From source file:org.acdd.launcher.welcome.WelcomeFragment.java
@Override public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { View imageView = null;/* w w w .j a v a 2 s . c o m*/ // super.onCreate(bundle); this.mHandler = new Handler(this); ViewGroup viewGroup2 = (ViewGroup) layoutInflater.inflate(R.layout.welcome, viewGroup, false); final PathView pathView = (PathView) viewGroup2.findViewById(R.id.pathViewS); PathView pathViewJ = (PathView) viewGroup2.findViewById(R.id.pathViewJ); PathView pathViewT = (PathView) viewGroup2.findViewById(R.id.pathViewT); PathView pathViewB = (PathView) viewGroup2.findViewById(R.id.pathViewB); // final Path path = makeConvexArrow(50, 100); // pathView.setPath(path); Log.d("ver", Build.VERSION.SDK_INT + "<<<<<"); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) { pathView.setFillAfter(true); pathView.useNaturalColors(); pathView.getPathAnimator().delay(100).duration(1500) .interpolator(new AccelerateDecelerateInterpolator()).start(); pathViewJ.setFillAfter(true); pathViewJ.useNaturalColors(); pathViewJ.getPathAnimator().delay(100).duration(1500) .interpolator(new AccelerateDecelerateInterpolator()).start(); pathViewT.setFillAfter(true); pathViewT.useNaturalColors(); pathViewT.getPathAnimator().delay(100).duration(1500) .interpolator(new AccelerateDecelerateInterpolator()).start(); pathViewB.setFillAfter(true); pathViewB.useNaturalColors(); pathViewB.getPathAnimator().delay(100).duration(1500) .interpolator(new AccelerateDecelerateInterpolator()).start(); } init(); return viewGroup2; }
From source file:com.grottworkshop.gwscirclereveal.animation.ViewAnimationUtils.java
/** * Lifting view/* w ww .j a va 2s .c o m*/ * * @param view The animation target * @param baseRotation initial Rotation X in 3D space * @param duration aniamtion duration * @param startDelay start delay before animation begin */ @Deprecated public static void liftingFromBottom(View view, float baseRotation, int duration, int startDelay) { view.setRotationX(baseRotation); view.setTranslationY(view.getHeight() / 3); animate(view).setInterpolator(new AccelerateDecelerateInterpolator()).setDuration(duration) .setStartDelay(startDelay).rotationX(0).translationY(0).start(); }
From source file:com.echo.holographlibrarysample.PieFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.fragment_piegraph, container, false); final Resources resources = getResources(); final PieGraph pg = (PieGraph) v.findViewById(R.id.piegraph); final Button animateButton = (Button) v.findViewById(R.id.animatePieButton); PieSlice slice = new PieSlice(); slice.setColor(resources.getColor(R.color.green_light)); slice.setSelectedColor(resources.getColor(R.color.transparent_orange)); slice.setValue(2);// w ww . jav a 2 s . com slice.setTitle("first"); pg.addSlice(slice); slice = new PieSlice(); slice.setColor(resources.getColor(R.color.orange)); slice.setValue(3); pg.addSlice(slice); slice = new PieSlice(); slice.setColor(resources.getColor(R.color.purple)); slice.setValue(8); pg.addSlice(slice); pg.setOnSliceClickedListener(new OnSliceClickedListener() { @Override public void onClick(int index) { Toast.makeText(getActivity(), "Slice " + index + " clicked", Toast.LENGTH_SHORT).show(); } }); Bitmap b = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); pg.setBackgroundBitmap(b); SeekBar seekBar = (SeekBar) v.findViewById(R.id.seekBarRatio); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { pg.setInnerCircleRatio(progress); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); seekBar = (SeekBar) v.findViewById(R.id.seekBarPadding); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { pg.setPadding(progress); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) animateButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { for (PieSlice s : pg.getSlices()) s.setGoalValue((float) Math.random() * 10); pg.setDuration(1000);//default if unspecified is 300 ms pg.setInterpolator(new AccelerateDecelerateInterpolator());//default if unspecified is linear; constant speed pg.setAnimationListener(getAnimationListener()); pg.animateToGoalValues();//animation will always overwrite. Pass true to call the onAnimationCancel Listener with onAnimationEnd } }); return v; }
From source file:com.echo.holographlibrarysample.BarFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.fragment_bargraph, container, false); final Resources resources = getResources(); ArrayList<Bar> aBars = new ArrayList<Bar>(); Bar bar = new Bar(); bar.setColor(resources.getColor(R.color.green_light)); bar.setSelectedColor(resources.getColor(R.color.transparent_orange)); bar.setName("Test1"); bar.setValue(1000);/*from ww w. ja va 2 s . co m*/ bar.setValueString("$1,000"); aBars.add(bar); bar = new Bar(); bar.setColor(resources.getColor(R.color.orange)); bar.setName("Test2"); bar.setValue(2000); bar.setValueString("$2,000"); aBars.add(bar); bar = new Bar(); bar.setColor(resources.getColor(R.color.purple)); bar.setName("Test3"); bar.setValue(1500); bar.setValueString("$1,500"); aBars.add(bar); final BarGraph barGraph = (BarGraph) v.findViewById(R.id.bargraph); bg = barGraph; barGraph.setBars(aBars); barGraph.setOnBarClickedListener(new OnBarClickedListener() { @Override public void onClick(int index) { Toast.makeText(getActivity(), "Bar " + index + " clicked " + String.valueOf(barGraph.getBars().get(index).getValue()), Toast.LENGTH_SHORT).show(); } }); Button animateBarButton = (Button) v.findViewById(R.id.animateBarButton); Button animateInsertBarButton = (Button) v.findViewById(R.id.animateInsertBarButton); Button animateDelteBarButton = (Button) v.findViewById(R.id.animateDeleteBarButton); //animate to random values animateBarButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { for (Bar b : barGraph.getBars()) { b.setGoalValue((float) Math.random() * 1000); b.setValuePrefix("$");//display the prefix throughout the animation Log.d("goal val", String.valueOf(b.getGoalValue())); } barGraph.setDuration(1200);//default if unspecified is 300 ms barGraph.setInterpolator(new AccelerateDecelerateInterpolator());//Only use over/undershoot when not inserting/deleting barGraph.setAnimationListener(getAnimationListener()); barGraph.animateToGoalValues(); } }); //insert a bar animateInsertBarButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { barGraph.cancelAnimating(); //must clear existing to call onAnimationEndListener cleanup BEFORE adding new bars int newPosition = barGraph.getBars().size() == 0 ? 0 : new Random().nextInt(barGraph.getBars().size()); Bar bar = new Bar(); bar.setColor(Color.parseColor("#AA0000FF")); bar.setName("Insert bar " + String.valueOf(barGraph.getBars().size())); bar.setValue(0); bar.mAnimateSpecial = HoloGraphAnimate.ANIMATE_INSERT; barGraph.getBars().add(newPosition, bar); for (Bar b : barGraph.getBars()) { b.setGoalValue((float) Math.random() * 1000); b.setValuePrefix("$");//display the prefix throughout the animation Log.d("goal val", String.valueOf(b.getGoalValue())); } barGraph.setDuration(1200);//default if unspecified is 300 ms barGraph.setInterpolator(new AccelerateDecelerateInterpolator());//Don't use over/undershoot interpolator for insert/delete barGraph.setAnimationListener(getAnimationListener()); barGraph.animateToGoalValues(); } }); //delete a bar animateDelteBarButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { barGraph.cancelAnimating(); //must clear existing to call onAnimationEndListener cleanup BEFORE adding new bars if (barGraph.getBars().size() == 0) return; for (Bar b : barGraph.getBars()) { b.setGoalValue((float) Math.random() * 1000); b.setValuePrefix("$");//display the prefix throughout the animation Log.d("goal val", String.valueOf(b.getGoalValue())); } int newPosition = new Random().nextInt(barGraph.getBars().size()); Bar bar = barGraph.getBars().get(newPosition); bar.mAnimateSpecial = HoloGraphAnimate.ANIMATE_DELETE; bar.setGoalValue(0);//animate to 0 then delete barGraph.setDuration(1200);//default if unspecified is 300 ms barGraph.setInterpolator(new AccelerateInterpolator());//Don't use over/undershoot interpolator for insert/delete barGraph.setAnimationListener(getAnimationListener()); barGraph.animateToGoalValues(); } }); return v; }