Search in sources :

Example 31 with BounceInterpolator

use of android.view.animation.BounceInterpolator in project WilliamChart by diogobernardino.

the class LineCardOne method show.

@Override
public void show(Runnable action) {
    super.show(action);
    // Tooltip
    mTip = new Tooltip(mContext, R.layout.linechart_three_tooltip, R.id.value);
    ((TextView) mTip.findViewById(R.id.value)).setTypeface(Typeface.createFromAsset(mContext.getAssets(), "OpenSans-Semibold.ttf"));
    mTip.setVerticalAlignment(Tooltip.Alignment.BOTTOM_TOP);
    mTip.setDimensions((int) Tools.fromDpToPx(58), (int) Tools.fromDpToPx(25));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        mTip.setEnterAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 1), PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f), PropertyValuesHolder.ofFloat(View.SCALE_X, 1f)).setDuration(200);
        mTip.setExitAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 0), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f), PropertyValuesHolder.ofFloat(View.SCALE_X, 0f)).setDuration(200);
        mTip.setPivotX(Tools.fromDpToPx(65) / 2);
        mTip.setPivotY(Tools.fromDpToPx(25));
    }
    // Data
    LineSet dataset = new LineSet(mLabels, mValues[0]);
    dataset.setColor(Color.parseColor("#758cbb")).setFill(Color.parseColor("#2d374c")).setDotsColor(Color.parseColor("#758cbb")).setThickness(4).setDashed(new float[] { 10f, 10f }).beginAt(5);
    mChart.addData(dataset);
    dataset = new LineSet(mLabels, mValues[0]);
    dataset.setColor(Color.parseColor("#b3b5bb")).setFill(Color.parseColor("#2d374c")).setDotsColor(Color.parseColor("#ffc755")).setThickness(4).endAt(6);
    mChart.addData(dataset);
    mBaseAction = action;
    Runnable chartAction = new Runnable() {

        @Override
        public void run() {
            mBaseAction.run();
            mTip.prepare(mChart.getEntriesArea(0).get(3), mValues[0][3]);
            mChart.showTooltip(mTip, true);
        }
    };
    mChart.setAxisBorderValues(0, 20).setYLabels(AxisRenderer.LabelPosition.NONE).setTooltips(mTip).show(new Animation().setInterpolator(new BounceInterpolator()).fromAlpha(0).withEndAction(chartAction));
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) Tooltip(com.db.chart.tooltip.Tooltip) Animation(com.db.chart.animation.Animation) TextView(android.widget.TextView) LineSet(com.db.chart.model.LineSet)

Example 32 with BounceInterpolator

use of android.view.animation.BounceInterpolator in project ViewAnimator by florent37.

the class ViewAnimatorMainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view_animator_activity_main);
    image = (ImageView) findViewById(R.id.image);
    mountain = (ImageView) findViewById(R.id.mountain);
    text = (TextView) findViewById(R.id.text);
    percent = (TextView) findViewById(R.id.percent);
    findViewById(R.id.parallel).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            animateParallel();
        }
    });
    findViewById(R.id.mountain).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            simpleAnimation();
        }
    });
    findViewById(R.id.sequentially).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            animateSequentially();
        }
    });
    findViewById(R.id.enhanced).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            int random = new Random().nextInt(10);
            final ViewGroup viewGroup = (ViewGroup) v.getParent();
            final ImageView imageView = new ImageView(v.getContext());
            imageView.setImageResource(R.mipmap.ic_launcher);
            viewGroup.addView(imageView);
            AnimationBuilder builder;
            switch(random) {
                case 0:
                    builder = ViewAnimator.animate(imageView).shake().interpolator(new LinearInterpolator());
                    break;
                case 1:
                    builder = ViewAnimator.animate(imageView).bounceIn().interpolator(new BounceInterpolator());
                    break;
                case 2:
                    builder = ViewAnimator.animate(imageView).flash().repeatCount(4);
                    break;
                case 3:
                    builder = ViewAnimator.animate(imageView).flipHorizontal();
                    break;
                case 4:
                    builder = ViewAnimator.animate(imageView).wave().duration(5000);
                    break;
                case 5:
                    builder = ViewAnimator.animate(imageView).tada();
                    break;
                case 6:
                    builder = ViewAnimator.animate(imageView).pulse();
                    break;
                case 7:
                    builder = ViewAnimator.animate(imageView).standUp();
                    break;
                case 8:
                    builder = ViewAnimator.animate(imageView).swing();
                    break;
                default:
                    builder = ViewAnimator.animate(imageView).wobble();
                    break;
            }
            builder.onStop(new AnimationListener.Stop() {

                @Override
                public void onStop() {
                    viewGroup.removeView(imageView);
                }
            }).start();
        }
    });
    findViewById(R.id.path).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Path path = new Path();
            path.moveTo(START_POINT[0], START_POINT[1]);
            path.quadTo(RIGHT_CONTROL_POINT[0], RIGHT_CONTROL_POINT[1], BOTTOM_POINT[0], BOTTOM_POINT[1]);
            path.quadTo(LEFT_CONTROL_POINT[0], LEFT_CONTROL_POINT[1], START_POINT[0], START_POINT[1]);
            path.close();
            ViewAnimator.animate(v).path(path).repeatCount(2).start();
        }
    });
    findViewById(R.id.svgPath).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ViewAnimator.animate(v).svgPath(SVG_PATH).duration(10000).repeatCount(3).start();
            final View btnWave = findViewById(R.id.wave);
            btnWave.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    ViewAnimator.animate(btnWave).wave().duration(3000).start();
                }
            });
            final View btnShake = findViewById(R.id.shake);
            btnShake.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    ViewAnimator.animate(btnShake).shake().duration(3000).start();
                }
            });
        }
    });
}
Also used : Path(android.graphics.Path) ViewGroup(android.view.ViewGroup) BounceInterpolator(android.view.animation.BounceInterpolator) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Random(java.util.Random) LinearInterpolator(android.view.animation.LinearInterpolator) ImageView(android.widget.ImageView) AnimationBuilder(com.github.florent37.viewanimator.AnimationBuilder) AnimationListener(com.github.florent37.viewanimator.AnimationListener)

Aggregations

BounceInterpolator (android.view.animation.BounceInterpolator)32 View (android.view.View)10 ImageView (android.widget.ImageView)8 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)6 LinearInterpolator (android.view.animation.LinearInterpolator)6 TextView (android.widget.TextView)6 ObjectAnimator (android.animation.ObjectAnimator)5 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)5 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)4 AnticipateInterpolator (android.view.animation.AnticipateInterpolator)4 AnticipateOvershootInterpolator (android.view.animation.AnticipateOvershootInterpolator)4 Interpolator (android.view.animation.Interpolator)4 OvershootInterpolator (android.view.animation.OvershootInterpolator)4 Scroller (android.widget.Scroller)4 Animator (android.animation.Animator)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 ViewGroup (android.view.ViewGroup)3 Animation (com.db.chart.animation.Animation)3 ValueAnimator (android.animation.ValueAnimator)2 SuppressLint (android.annotation.SuppressLint)2