Search in sources :

Example 1 with StateListAnimator

use of android.animation.StateListAnimator in project Shuttle by timusus.

the class CustomSwappingHolder method refreshChrome.

private void refreshChrome() {
    Drawable backgroundDrawable = this.mIsSelectable ? this.mSelectionModeBackgroundDrawable : this.mDefaultModeBackgroundDrawable;
    this.itemView.setBackgroundDrawable(backgroundDrawable);
    if (backgroundDrawable != null) {
        backgroundDrawable.jumpToCurrentState();
    }
    if (VERSION.SDK_INT >= 21) {
        StateListAnimator animator = this.mIsSelectable ? this.mSelectionModeStateListAnimator : this.mDefaultModeStateListAnimator;
        this.itemView.setStateListAnimator(animator);
        if (animator != null) {
            animator.jumpToCurrentState();
        }
    }
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) StateListAnimator(android.animation.StateListAnimator)

Example 2 with StateListAnimator

use of android.animation.StateListAnimator in project Shuttle by timusus.

the class CustomSwappingHolder method setDefaultModeStateListAnimator.

public void setDefaultModeStateListAnimator(int resId) {
    if (VERSION.SDK_INT >= 21) {
        StateListAnimator animator = AnimatorInflater.loadStateListAnimator(this.itemView.getContext(), resId);
        this.setDefaultModeStateListAnimator(animator);
    }
}
Also used : StateListAnimator(android.animation.StateListAnimator)

Example 3 with StateListAnimator

use of android.animation.StateListAnimator in project Shuttle by timusus.

the class CustomSwappingHolder method setSelectionModeStateListAnimator.

public void setSelectionModeStateListAnimator(int resId) {
    if (VERSION.SDK_INT >= 21) {
        StateListAnimator animator = AnimatorInflater.loadStateListAnimator(this.itemView.getContext(), resId);
        this.setSelectionModeStateListAnimator(animator);
    }
}
Also used : StateListAnimator(android.animation.StateListAnimator)

Example 4 with StateListAnimator

use of android.animation.StateListAnimator in project material-components-android by material-components.

the class ViewUtilsLollipop method setDefaultAppBarLayoutStateListAnimator.

/** Creates and sets a {@link StateListAnimator} with a custom elevation value */
static void setDefaultAppBarLayoutStateListAnimator(final View view, final float elevation) {
    final int dur = view.getResources().getInteger(R.integer.app_bar_elevation_anim_duration);
    final StateListAnimator sla = new StateListAnimator();
    // Enabled and collapsible, but not collapsed means not elevated
    sla.addState(new int[] { android.R.attr.enabled, R.attr.state_collapsible, -R.attr.state_collapsed }, ObjectAnimator.ofFloat(view, "elevation", 0f).setDuration(dur));
    // Default enabled state
    sla.addState(new int[] { android.R.attr.enabled }, ObjectAnimator.ofFloat(view, "elevation", elevation).setDuration(dur));
    // Disabled state
    sla.addState(new int[0], ObjectAnimator.ofFloat(view, "elevation", 0).setDuration(0));
    view.setStateListAnimator(sla);
}
Also used : StateListAnimator(android.animation.StateListAnimator)

Example 5 with StateListAnimator

use of android.animation.StateListAnimator in project FloatingActionButton by makovkastar.

the class FloatingActionButton method init.

@SuppressLint("NewApi")
private void init(Context context, AttributeSet attributeSet) {
    mVisible = true;
    mColorNormal = getColor(R.color.material_blue_500);
    mColorPressed = darkenColor(mColorNormal);
    mColorRipple = lightenColor(mColorNormal);
    mColorDisabled = getColor(android.R.color.darker_gray);
    mType = TYPE_NORMAL;
    mShadow = true;
    mScrollThreshold = getResources().getDimensionPixelOffset(R.dimen.fab_scroll_threshold);
    mShadowSize = getDimension(R.dimen.fab_shadow_size);
    if (hasLollipopApi()) {
        StateListAnimator stateListAnimator = AnimatorInflater.loadStateListAnimator(context, R.anim.fab_press_elevation);
        setStateListAnimator(stateListAnimator);
    }
    if (attributeSet != null) {
        initAttributes(context, attributeSet);
    }
    updateBackground();
}
Also used : StateListAnimator(android.animation.StateListAnimator) SuppressLint(android.annotation.SuppressLint)

Aggregations

StateListAnimator (android.animation.StateListAnimator)25 SuppressLint (android.annotation.SuppressLint)11 Drawable (android.graphics.drawable.Drawable)10 View (android.view.View)10 ImageView (android.widget.ImageView)10 Outline (android.graphics.Outline)9 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)9 ViewOutlineProvider (android.view.ViewOutlineProvider)9 ActionBar (org.telegram.ui.ActionBar.ActionBar)9 CombinedDrawable (org.telegram.ui.Components.CombinedDrawable)9 AnimatorSet (android.animation.AnimatorSet)8 Context (android.content.Context)8 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)8 RecyclerView (androidx.recyclerview.widget.RecyclerView)8 RecyclerListView (org.telegram.ui.Components.RecyclerListView)8 Paint (android.graphics.Paint)7 ViewGroup (android.view.ViewGroup)7 FrameLayout (android.widget.FrameLayout)7 Animator (android.animation.Animator)6 ObjectAnimator (android.animation.ObjectAnimator)6