List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter
AnimatorListenerAdapter
From source file:Main.java
public static ObjectAnimator inflateFadeIn(final View v) { PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0f, 1f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0f, 1f); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f, 1f); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(v, scaleX, scaleY, alpha); animator.setDuration(ANIM_DURATION_INFLATE); animator.addListener(new AnimatorListenerAdapter() { @Override/*from ww w . ja va 2 s.c om*/ public void onAnimationStart(Animator animation) { v.setVisibility(View.VISIBLE); } }); return animator; }
From source file:Main.java
public static void animateTextViewMaxLinesChange(final TextView textView, final int maxLines, final int duration) { final int startHeight = textView.getMeasuredHeight(); textView.setMaxLines(maxLines);//from w w w . java2 s . c om textView.measure(View.MeasureSpec.makeMeasureSpec(textView.getWidth(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); final int endHeight = textView.getMeasuredHeight(); ObjectAnimator animation = ObjectAnimator.ofInt(textView, MAX_HEIGHT_ATTR, startHeight, endHeight); animation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (textView.getMaxHeight() == endHeight) { textView.setMaxLines(maxLines); } } } ); animation.setDuration(duration).start(); }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private static void hide(final View view, int cornerType, int animRes, final boolean goneOrInvisible, final AnimatorListenerAdapter listener) { int[] amaya = calulateCorner(view, cornerType); // if(view) Animator anim = ViewAnimationUtils.createCircularReveal(view, amaya[0], amaya[1], amaya[2], 0); anim.addListener(new AnimatorListenerAdapter() { @Override/*from w ww . j a v a 2 s.co m*/ public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(goneOrInvisible ? View.GONE : View.INVISIBLE); if (listener != null) listener.onAnimationEnd(animation); } }); anim.setDuration(300); anim.start(); }
From source file:Main.java
public static void enterReveal(final View view) { view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override//w ww. j a v a 2s . c o m public void onGlobalLayout() { Animator animator = null; view.getViewTreeObserver().removeOnGlobalLayoutListener(this); int cx = view.getMeasuredWidth() / 2; int cy = view.getMeasuredHeight() / 2; try { final int finalRadius = Math.max(view.getWidth(), view.getHeight()) / 2 + 125; animator = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); } }); } catch (Exception ignored) { } view.setVisibility(View.VISIBLE); if (animator != null) { animator.start(); } } }); }
From source file:Main.java
public static Animator createCircularHideAnimator(final View view, @Nullable Animator.AnimatorListener listener) { if (view.getWindowToken() == null || view.getVisibility() == View.INVISIBLE) return null; // get the center for the clipping circle int cx = (view.getLeft() + view.getRight()) / 2; int cy = (view.getTop() + view.getBottom()) / 2; // get the initial radius for the clipping circle int initialRadius = view.getWidth(); // create the animation (the final radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0); anim.addListener(new AnimatorListenerAdapter() { @Override/* w w w.j a v a 2s . com*/ public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(View.INVISIBLE); } }); if (listener != null) { anim.addListener(listener); } return anim; }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) public static void showProgress(Activity activity, final View defaultView, final View progressView, final boolean show) { // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow // for very easy animations. If available, use these APIs to fade-in // the progress spinner. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { int shortAnimTime = activity.getResources().getInteger(android.R.integer.config_shortAnimTime); defaultView.setVisibility(show ? View.GONE : View.VISIBLE); defaultView.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1) .setListener(new AnimatorListenerAdapter() { @Override//from w w w . java 2 s . co m public void onAnimationEnd(Animator animation) { defaultView.setVisibility(show ? View.GONE : View.VISIBLE); } }); progressView.setVisibility(show ? View.VISIBLE : View.GONE); progressView.animate().setDuration(shortAnimTime).alpha(show ? 1 : 0) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { progressView.setVisibility(show ? View.VISIBLE : View.GONE); } }); } else { // The ViewPropertyAnimator APIs are not available, so simply show // and hide the relevant UI components. progressView.setVisibility(show ? View.VISIBLE : View.GONE); defaultView.setVisibility(show ? View.GONE : View.VISIBLE); } }
From source file:Main.java
public static Animator createCircularShowAnimator(final View view) { if (view.getVisibility() == View.VISIBLE || view.getWindowToken() == null) return null; // get the center for the clipping circle int cx = (view.getLeft() + view.getRight()) / 2; int cy = (view.getTop() + view.getBottom()) / 2; // get the final radius for the clipping circle int finalRadius = view.getWidth(); // create and start the animator for this view // (the start radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius); anim.addListener(new AnimatorListenerAdapter() { @Override/*from w w w . j av a 2 s .c o m*/ public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); view.setVisibility(View.VISIBLE); } }); return anim; }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void show(final View view, final int cornerType, int normalAnimRes, final AnimatorListenerAdapter listener) { try {//from w w w .jav a 2 s . c om int[] amaya = calulateCorner(view, cornerType); Animator anim = ViewAnimationUtils.createCircularReveal(view, amaya[0], amaya[1], 0, amaya[2]); anim.setInterpolator(new LinearInterpolator()); anim.setDuration(300); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); view.setVisibility(View.VISIBLE); if (listener != null) { listener.onAnimationStart(animation); } } }); anim.start(); } catch (Exception e) { e.printStackTrace(); view.setVisibility(View.VISIBLE); } }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) public static ViewPropertyAnimator fadeOut(final View from, int duration) { if (from.getVisibility() == View.VISIBLE) { from.clearAnimation();/*from www . jav a 2 s .c om*/ final ViewPropertyAnimator animator = from.animate(); animator.alpha(0f).setDuration(duration).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { from.setVisibility(View.INVISIBLE); from.setAlpha(1f); } }); return animator; } return null; }
From source file:Main.java
public static ObjectAnimator alpha_to(final View target) { ObjectAnimator objectAnimator = null; if (null != target) { objectAnimator = ObjectAnimator.ofFloat(target, View.ALPHA, 1f, 0f) .setDuration(BUBBLE_ANIMATION_DURATION); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override/*from ww w . j ava 2s . c o m*/ public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); target.setVisibility(View.GONE); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); target.setVisibility(View.GONE); } }); objectAnimator.start(); } return objectAnimator; }