private static StateListAnimator getRaiseStateListAnimator(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return AnimatorInflater.loadStateListAnimator(context, R.anim.raise); } else { return null; } }
/** * Set the state list animator to use when in default mode. If not run on a Lollipop device, this * method is a no-op. * * @param resId A state list animator resource id. Ignored prior to Lollipop. */ public void setDefaultModeStateListAnimator(int resId) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { StateListAnimator animator = AnimatorInflater.loadStateListAnimator(itemView.getContext(), resId); setDefaultModeStateListAnimator(animator); } }
@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(); }