Search in sources :

Example 11 with OnPreDrawListener

use of android.view.ViewTreeObserver.OnPreDrawListener in project UltimateAndroid by cymcsg.

the class FilckerAnimationListView method doAnimation.

private void doAnimation() {
    setEnabled(false);
    animating = true;
    final float durationUnit = (float) MAX_ANIM_DURATION / getHeight();
    animatePreLayout(durationUnit, new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(final Animator animation) {
            adapter.notifyDataSetChanged();
            getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

                @Override
                public boolean onPreDraw() {
                    getViewTreeObserver().removeOnPreDrawListener(this);
                    animatePostLayout(durationUnit);
                    return true;
                }
            });
        }
    });
}
Also used : Animator(com.marshalchen.common.uimodule.nineoldandroids.animation.Animator) ObjectAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ObjectAnimator) AnimatorListenerAdapter(com.marshalchen.common.uimodule.nineoldandroids.animation.AnimatorListenerAdapter) OnPreDrawListener(android.view.ViewTreeObserver.OnPreDrawListener)

Example 12 with OnPreDrawListener

use of android.view.ViewTreeObserver.OnPreDrawListener in project UltimateAndroid by cymcsg.

the class HomeArc method init.

public void init(int score) {
    this.score = score;
    Resources res = getResources();
    tb = res.getDimension(R.dimen.historyscore_tb);
    paint_black = new Paint();
    paint_black.setAntiAlias(true);
    paint_black.setColor(blackColor);
    paint_black.setStrokeWidth(tb * 0.2f);
    paint_black.setStyle(Style.STROKE);
    paint_white = new Paint();
    paint_white.setAntiAlias(true);
    paint_white.setColor(whiteColor);
    paint_white.setTextSize(tb * 6.0f);
    paint_white.setStrokeWidth(tb * 0.2f);
    paint_white.setTextAlign(Align.CENTER);
    paint_white.setStyle(Style.STROKE);
    rectf = new RectF();
    rectf.set(tb * 0.5f, tb * 0.5f, tb * 18.5f, tb * 18.5f);
    setLayoutParams(new LayoutParams((int) (tb * 19.5f), (int) (tb * 19.5f)));
    this.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

        public boolean onPreDraw() {
            new thread();
            getViewTreeObserver().removeOnPreDrawListener(this);
            return false;
        }
    });
}
Also used : RectF(android.graphics.RectF) LayoutParams(android.view.ViewGroup.LayoutParams) Resources(android.content.res.Resources) Paint(android.graphics.Paint) OnPreDrawListener(android.view.ViewTreeObserver.OnPreDrawListener)

Aggregations

OnPreDrawListener (android.view.ViewTreeObserver.OnPreDrawListener)12 View (android.view.View)5 AnimatorSet (android.animation.AnimatorSet)2 ViewGroup (android.view.ViewGroup)2 LayoutParams (android.view.ViewGroup.LayoutParams)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ObjectAnimator (android.animation.ObjectAnimator)1 Resources (android.content.res.Resources)1 Bitmap (android.graphics.Bitmap)1 Outline (android.graphics.Outline)1 Paint (android.graphics.Paint)1 Rect (android.graphics.Rect)1 RectF (android.graphics.RectF)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 ViewOutlineProvider (android.view.ViewOutlineProvider)1