Search in sources :

Example 1 with ReverseInterpolator

use of io.codetailps.animation.ReverseInterpolator in project PersistentSearch by KieronQuinn.

the class SearchBox method hideCircularly.

/***
     * Hide the searchbox using the circle animation. Can be called regardless of result list length
     * @param activity Activity
     */
public void hideCircularly(int x, int y, Activity activity) {
    final FrameLayout layout = (FrameLayout) activity.getWindow().getDecorView().findViewById(android.R.id.content);
    RelativeLayout root = (RelativeLayout) findViewById(R.id.search_root);
    Resources r = getResources();
    float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96, r.getDisplayMetrics());
    int finalRadius = (int) Math.max(layout.getWidth() * 1.5, px);
    SupportAnimator animator = ViewAnimationUtils.createCircularReveal(root, x, y, 0, finalRadius);
    animator.setInterpolator(new ReverseInterpolator());
    animator.setDuration(500);
    animator.start();
    animator.addListener(new SupportAnimator.AnimatorListener() {

        @Override
        public void onAnimationStart() {
        }

        @Override
        public void onAnimationEnd() {
            setVisibility(View.GONE);
        }

        @Override
        public void onAnimationCancel() {
        }

        @Override
        public void onAnimationRepeat() {
        }
    });
}
Also used : SupportAnimator(io.codetailps.animation.SupportAnimator) FrameLayout(android.widget.FrameLayout) RelativeLayout(android.widget.RelativeLayout) ReverseInterpolator(io.codetailps.animation.ReverseInterpolator) Resources(android.content.res.Resources)

Aggregations

Resources (android.content.res.Resources)1 FrameLayout (android.widget.FrameLayout)1 RelativeLayout (android.widget.RelativeLayout)1 ReverseInterpolator (io.codetailps.animation.ReverseInterpolator)1 SupportAnimator (io.codetailps.animation.SupportAnimator)1