List of usage examples for android.view ViewAnimationUtils createCircularReveal
public static Animator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius)
From source file:tech.salroid.filmy.fragment.AllTrailerFragment.java
@Nullable @Override/*from w w w .ja v a 2s . co m*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); nightMode = sp.getBoolean("dark", false); View view = inflater.inflate(R.layout.all_trailer_layout, container, false); ButterKnife.bind(this, view); if (!nightMode) allThemeLogic(); else { nightModeLogic(); } crossButton.setOnClickListener(this); // To run the animation as soon as the view is layout in the view hierarchy we add this // listener and remove it // as soon as it runs to prevent multiple animations if the view changes bounds view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { v.removeOnLayoutChangeListener(this); int cx = getArguments().getInt("cx"); int cy = getArguments().getInt("cy"); // get the hypothenuse so the radius is from one corner to the other int radius = (int) Math.hypot(right, bottom); Animator reveal; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { reveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, radius); reveal.setInterpolator(new DecelerateInterpolator(2f)); reveal.setDuration(1000); reveal.start(); } } }); init(view); return view; }
From source file:com.ruesga.rview.fragments.RevealDialogFragment.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void performEnterRevealTransition() { if (!mDoReveal || getDialog() == null || getDialog().getWindow() == null) { mDoReveal = false;//from www . jav a2s .c om return; } final View v = getDialog().getWindow().getDecorView(); if (!v.isAttachedToWindow()) { mDoReveal = false; return; } v.setVisibility(View.VISIBLE); Rect dialogRect = computeViewOnScreen(v); int cx = v.getMeasuredWidth() / 2; int cy = v.getMeasuredHeight() / 2; if (mAnchorRect != null) { cx = Math.min(Math.max(mAnchorRect.centerX(), dialogRect.left), dialogRect.right) - dialogRect.left; cy = Math.min(Math.max(mAnchorRect.centerY(), dialogRect.top), dialogRect.bottom) - dialogRect.top; } int finalRadius = Math.max(v.getWidth(), v.getHeight()); Animator anim = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, finalRadius); anim.setDuration(350); anim.setInterpolator(new AccelerateInterpolator()); anim.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { onDialogReveled(); mDoReveal = false; } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); anim.start(); }
From source file:ooo.oxo.apps.materialize.SearchPanelController.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private Animator makeSearchPanelAnimator(boolean reverse) { int width = container.getWidth(); int centerX = container.getRight() + container.getPaddingRight() - resources.getDimensionPixelOffset(R.dimen.reveal_right) / 4 * 3; int centerY = container.getHeight() / 2; Animator animator = ViewAnimationUtils.createCircularReveal(container, centerX, centerY, reverse ? width : 0, reverse ? 0 : width); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.setDuration(resources.getInteger(android.R.integer.config_mediumAnimTime)); return animator; }
From source file:com.numix.calculator.EventListener.java
private void deleteAnimation(View view) { final TextView colorLayout = (TextView) view.getRootView().findViewById(R.id.deleteColor); final LinearLayout displayView = (LinearLayout) view.getRootView().findViewById(R.id.displayLayout); final CalculatorDisplay calculatorDisplay = (CalculatorDisplay) view.getRootView() .findViewById(R.id.display); int finalRadius = Math.max(displayView.getWidth(), displayView.getHeight()); // create the animator for this view (the start radius is zero) Animator colorAnim;// w w w . j ava2s . c om colorAnim = ViewAnimationUtils.createCircularReveal(colorLayout, (int) displayView.getRight(), (int) displayView.getBottom(), 0, finalRadius); final AlphaAnimation fadeAnim = new AlphaAnimation(1.0f, 0.0f); final AlphaAnimation fadeDisplay = new AlphaAnimation(1.0f, 0.0f); fadeAnim.setDuration(250); fadeAnim.setInterpolator(new AccelerateInterpolator()); fadeAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { colorLayout.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); fadeDisplay.setDuration(250); fadeDisplay.setInterpolator(new AccelerateInterpolator()); fadeDisplay.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mHandler.onClear(); displayView.setAlpha(1.0f); } @Override public void onAnimationRepeat(Animation animation) { } }); colorAnim.setInterpolator(new AccelerateInterpolator()); colorAnim.addListener(new android.animation.Animator.AnimatorListener() { @Override public void onAnimationStart(android.animation.Animator animation) { calculatorDisplay.startAnimation(fadeDisplay); } @Override public void onAnimationRepeat(android.animation.Animator animation) { } @Override public void onAnimationEnd(android.animation.Animator animation) { colorLayout.startAnimation(fadeAnim); } @Override public void onAnimationCancel(android.animation.Animator animation) { } }); colorLayout.setVisibility(View.VISIBLE); colorAnim.start(); }
From source file:com.example.ray.firstapp.bottombar.MiscUtils.java
/** * Animate a background color change. Uses Circular Reveal if supported, * otherwise crossfades the background color in. * * @param clickedView the view that was clicked for calculating the start position * for the Circular Reveal. * @param backgroundView the currently showing background color. * @param bgOverlay the overlay view for the new background color that will be * animated in./*from w w w.j a v a 2 s . c o m*/ * @param newColor the new color. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) protected static void animateBGColorChange(View clickedView, final View backgroundView, final View bgOverlay, final int newColor) { int centerX = (int) (ViewCompat.getX(clickedView) + (clickedView.getMeasuredWidth() / 2)); int centerY = clickedView.getMeasuredHeight() / 2; int finalRadius = backgroundView.getWidth(); backgroundView.clearAnimation(); bgOverlay.clearAnimation(); Object animator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (!bgOverlay.isAttachedToWindow()) { return; } animator = ViewAnimationUtils.createCircularReveal(bgOverlay, centerX, centerY, 0, finalRadius); } else { ViewCompat.setAlpha(bgOverlay, 0); animator = ViewCompat.animate(bgOverlay).alpha(1); } if (animator instanceof ViewPropertyAnimatorCompat) { ((ViewPropertyAnimatorCompat) animator).setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationEnd(View view) { onCancel(); } @Override public void onAnimationCancel(View view) { onCancel(); } private void onCancel() { backgroundView.setBackgroundColor(newColor); bgOverlay.setVisibility(View.INVISIBLE); ViewCompat.setAlpha(bgOverlay, 1); } }).start(); } else if (animator != null) { ((Animator) animator).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { onCancel(); } @Override public void onAnimationCancel(Animator animation) { onCancel(); } private void onCancel() { backgroundView.setBackgroundColor(newColor); bgOverlay.setVisibility(View.INVISIBLE); ViewCompat.setAlpha(bgOverlay, 1); } }); ((Animator) animator).start(); } bgOverlay.setBackgroundColor(newColor); bgOverlay.setVisibility(View.VISIBLE); }
From source file:com.adkdevelopment.rssreader.utils.Utilities.java
/** * Animates RecyclerView card on click with revealing effect * @param viewHolder to make animation on *///from w ww.j a v a2 s . c o m @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void animationCard(RecyclerView.ViewHolder viewHolder) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (sBlueColor == 0) { sBlueColor = ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.colorPrimary); } if (sWhiteColor == 0) { sWhiteColor = ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.white); } int finalRadius = (int) Math.hypot(viewHolder.itemView.getWidth() / 2, viewHolder.itemView.getHeight() / 2); Animator anim = ViewAnimationUtils.createCircularReveal(viewHolder.itemView, viewHolder.itemView.getWidth() / 2, viewHolder.itemView.getHeight() / 2, 0, finalRadius); viewHolder.itemView.setBackgroundColor(sBlueColor); anim.start(); anim.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { viewHolder.itemView.setBackgroundColor(sWhiteColor); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); } }
From source file:liam.franco.selene.activities.MainActivity.java
private void animateOpenBottomFabSheet() { if (bottomFabBar != null && bottomFabBar.getVisibility() == View.INVISIBLE) { final int[] xy = ViewUtils.viewCoordinates(fab); Animator animator = ViewAnimationUtils.createCircularReveal(bottomFabBar, (xy[0] + (fab.getMeasuredWidth() >> 1)), -bottomFabBar.getHeight(), UIUtils.convertDpToPixel(56f, App.CONTEXT), Math.max(bottomFabBar.getWidth(), bottomFabBar.getHeight())); animator.setDuration(500);/*from w w w .j a v a 2s . c o m*/ animator.setStartDelay(7000); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { if (fab != null) { fab.setVisibility(View.GONE); } if (bottomFabBar != null) { bottomFabBar.setVisibility(View.VISIBLE); } } }); animator.start(); } }
From source file:com.chrynan.guitartuner.PitchFragment.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public void circularReveal(final float x, final float y) { if (x != -1 && y != -1) { float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight()); Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, (int) x, (int) y, 0, finalRadius); //viewRoot.setBackgroundColor(getActivity().getResources().getColor(R.color.white)); anim.setInterpolator(new DecelerateInterpolator(2f)); anim.setDuration(1000);//from w ww . java 2s . com anim.start(); } }
From source file:com.chrynan.guitartuner.PitchFragment.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public Animator unreveal(final float x, final float y) { Animator anim = ViewAnimationUtils.createCircularReveal(getView(), (int) x, (int) y, (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight()), 0); anim.setInterpolator(new AccelerateInterpolator(0.5f)); anim.setDuration(500);// w ww .j a v a 2s . c om return anim; }
From source file:uk.ac.hutton.ics.buntata.fragment.IntroNetworkFragment.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void circularShowView(final View view) { if (anim != null && anim.isRunning()) anim.end();// w w w .jav a 2s.c o m /* set the center for the clipping circle */ int cx = view.getWidth() / 2; int cy = view.getHeight(); /* get the final radius for the clipping circle */ float finalRadius = (float) Math.hypot(cx, cy); /* create the animator for this view (the start radius is zero) */ anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius); /* make the view visible and start the animation */ view.setVisibility(View.VISIBLE); anim.start(); }