Search in sources :

Example 21 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project iosched by google.

the class SessionDetailFragment method displayTrackColor.

/**
     * Update the header box background color & status bar color depending upon which track this
     * session belongs to.
     * <p>
     * Note this requires both the {@link SessionDetailQueryEnum#SESSIONS} &
     * {@link SessionDetailQueryEnum#TAG_METADATA) queries to have returned.
     */
private void displayTrackColor(SessionDetailModel data) {
    if (data.isSessionTrackColorAvailable()) {
        int trackColor = data.getSessionTrackColor();
        if (trackColor == Color.TRANSPARENT) {
            trackColor = UIUtils.getThemeColor(getContext(), R.attr.colorPrimary, R.color.theme_primary);
        }
        final Drawable background = mHeaderBox.getBackground();
        if (background instanceof ColorDrawable && ((ColorDrawable) background).getColor() == trackColor) {
            return;
        }
        // Animate the color change to make the transition smoother
        final ObjectAnimator color = ObjectAnimator.ofInt(mHeaderBox, UIUtils.BACKGROUND_COLOR, trackColor);
        color.setEvaluator(new ArgbEvaluator());
        if (mHasEnterTransition) {
            color.setStartDelay(200L);
        }
        color.setDuration(300L);
        color.start();
        if (mCollapsingToolbar.getFitsSystemWindows() && mPhotoViewContainer.getVisibility() == View.VISIBLE) {
            // immersive+photo
            mCollapsingToolbar.setStatusBarScrimColor(trackColor);
        } else {
            UIUtils.adjustAndSetStatusBarColor(getActivity(), trackColor);
        }
    }
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable)

Example 22 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project iosched by google.

the class SessionDetailFragment method returnTransitionStarted.

private void returnTransitionStarted() {
    // Fade the header bar for a smoother transition.
    final ObjectAnimator color = ObjectAnimator.ofInt(mHeaderBox, UIUtils.BACKGROUND_COLOR, ContextCompat.getColor(getContext(), R.color.background));
    color.setEvaluator(new ArgbEvaluator());
    color.setDuration(200L);
    color.start();
    // Also fade out the toolbar and FAB
    mToolbar.animate().alpha(0f).setDuration(200L).start();
    mAddScheduleFab.hide();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator)

Example 23 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project material-sheet-fab by gowong.

the class MaterialSheetAnimation method startColorAnim.

protected void startColorAnim(final View view, final int startColor, final int endColor, long duration, Interpolator interpolator, final AnimationListener listener) {
    // Setup animation
    ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), startColor, endColor);
    anim.setDuration(duration);
    anim.setInterpolator(interpolator);
    // Add listeners
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            if (listener != null) {
                listener.onStart();
            }
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (listener != null) {
                listener.onEnd();
            }
        }
    });
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            // Update background color
            Integer color = (Integer) animator.getAnimatedValue();
            // https://code.google.com/p/android/issues/detail?id=77843
            if (isSupportCardView) {
                // Use setCardBackground() method if it is available
                if (setCardBackgroundColor != null) {
                    try {
                        setCardBackgroundColor.invoke(sheet, color);
                    } catch (Exception e) {
                    // Ignore exceptions since there's no other way set a support CardView's
                    // background color
                    }
                }
            } else // Set background color for all other views
            {
                view.setBackgroundColor(color);
            }
        }
    });
    // Start animation
    anim.start();
}
Also used : Animator(android.animation.Animator) SupportAnimator(io.codetail.animation.SupportAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 24 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project DiscreteScrollView by yarolegovich.

the class GalleryActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery);
    evaluator = new ArgbEvaluator();
    currentOverlayColor = ContextCompat.getColor(this, R.color.galleryCurrentItemOverlay);
    overlayColor = ContextCompat.getColor(this, R.color.galleryItemOverlay);
    Gallery gallery = Gallery.get();
    List<Image> data = gallery.getData();
    DiscreteScrollView itemPicker = (DiscreteScrollView) findViewById(R.id.item_picker);
    itemPicker.setAdapter(new GalleryAdapter(data));
    itemPicker.setScrollListener(this);
    itemPicker.setOnItemChangedListener(this);
    itemPicker.scrollToPosition(1);
    findViewById(R.id.home).setOnClickListener(this);
    findViewById(R.id.fab_share).setOnClickListener(this);
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) DiscreteScrollView(com.yarolegovich.discretescrollview.DiscreteScrollView)

Example 25 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project MaterialLibrary by DeveloperPaul123.

the class CircularTextView method initialize.

/**
     * Initialize the view.
     */
private void initialize(Context context, AttributeSet attrs) {
    if (isInEditMode()) {
        text = "A";
        colors = new int[3];
        colors[0] = ColorGenerator.getRandomMaterialColor();
        colors[1] = ColorGenerator.getRandomMaterialColor();
        colors[2] = ColorGenerator.getRandomMaterialColor();
    } else {
        colors = new int[ColorGenerator.MATERIAL_COLORS_600.length];
        for (int i = 0; i < ColorGenerator.MATERIAL_COLORS_600.length; i++) {
            colors[i] = Color.parseColor(ColorGenerator.MATERIAL_COLORS_600[i]);
        }
    }
    mTextSize = getDimension(R.dimen.circular_text_size);
    maxTextSize = getDimension(R.dimen.circular_text_size);
    mSize = getDimension(R.dimen.circular_text_view_size);
    cx = mSize / 2;
    cy = cx;
    mPadding = getDimension(R.dimen.circular_text_view_padding);
    oneDp = getDimension(R.dimen.circular_text_view_one_dp);
    textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextSize(mTextSize);
    textPaint.setColor(getResources().getColor(android.R.color.white));
    textPaint.setAntiAlias(true);
    textPaint.setStrokeCap(Paint.Cap.ROUND);
    textPaint.setStrokeWidth(1);
    textPaint.setTextAlign(Paint.Align.CENTER);
    checkMarkPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    checkMarkPaint.setStrokeWidth(2 * oneDp);
    checkMarkPaint.setStyle(Paint.Style.STROKE);
    checkMarkPaint.setColor(getResources().getColor(android.R.color.white));
    checkMarkPaint.setStrokeCap(Paint.Cap.ROUND);
    checkMarkPaint.setAntiAlias(true);
    mColor = colors[new Random().nextInt(colors.length)];
    mSecondColor = getResources().getColor(R.color.circular_text_view_second_color);
    backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    backgroundPaint.setColor(mColor);
    backgroundPaint.setAntiAlias(true);
    backgroundPaint.setStrokeCap(Paint.Cap.ROUND);
    textAnimator = ObjectAnimator.ofFloat(this, "mTextSize", 0.0f, maxTextSize);
    textAnimator.setDuration(400);
    evaluator = new ArgbEvaluator();
    isBackShowing = false;
    gestureDetector = new GestureDetector(getContext(), new GestureListener());
}
Also used : Random(java.util.Random) ArgbEvaluator(android.animation.ArgbEvaluator) GestureDetector(android.view.GestureDetector) Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Aggregations

ArgbEvaluator (android.animation.ArgbEvaluator)58 ValueAnimator (android.animation.ValueAnimator)28 ObjectAnimator (android.animation.ObjectAnimator)18 Animator (android.animation.Animator)10 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)7 TargetApi (android.annotation.TargetApi)6 View (android.view.View)6 Paint (android.graphics.Paint)5 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)4 TextView (android.widget.TextView)4 SuppressLint (android.annotation.SuppressLint)3 ViewGroup (android.view.ViewGroup)3 AnimatorListener (android.animation.Animator.AnimatorListener)2 AnimatorSet (android.animation.AnimatorSet)2 PropertyValuesHolder (android.animation.PropertyValuesHolder)2 Intent (android.content.Intent)2 Drawable (android.graphics.drawable.Drawable)2 Toolbar (android.support.v7.widget.Toolbar)2