Search in sources :

Example 1 with SupportAnimator

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

the class SearchBox method revealFrom.

private void revealFrom(float x, float y, Activity a, SearchBox s) {
    FrameLayout layout = (FrameLayout) a.getWindow().getDecorView().findViewById(android.R.id.content);
    RelativeLayout root = (RelativeLayout) s.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(), px);
    SupportAnimator animator = ViewAnimationUtils.createCircularReveal(root, (int) x, (int) y, 0, finalRadius);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(500);
    animator.addListener(new SupportAnimator.AnimatorListener() {

        @Override
        public void onAnimationCancel() {
        }

        @Override
        public void onAnimationEnd() {
            toggleSearch();
        }

        @Override
        public void onAnimationRepeat() {
        }

        @Override
        public void onAnimationStart() {
        }
    });
    animator.start();
}
Also used : SupportAnimator(io.codetailps.animation.SupportAnimator) FrameLayout(android.widget.FrameLayout) RelativeLayout(android.widget.RelativeLayout) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) Resources(android.content.res.Resources)

Example 2 with SupportAnimator

use of io.codetailps.animation.SupportAnimator 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)2 FrameLayout (android.widget.FrameLayout)2 RelativeLayout (android.widget.RelativeLayout)2 SupportAnimator (io.codetailps.animation.SupportAnimator)2 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)1 ReverseInterpolator (io.codetailps.animation.ReverseInterpolator)1