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();
}
}
}
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);
}
}
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);
}
}
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);
}
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();
}
Aggregations