下面列出了android.graphics.drawable.Drawable#jumpToCurrentState() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@SuppressLint("NewApi")
public static void clearDrawableAnimation(View view)
{
if (Build.VERSION.SDK_INT < 21 || view == null)
{
return;
}
Drawable drawable;
if (view instanceof ListView)
{
drawable = ((ListView) view).getSelector();
if (drawable != null)
{
drawable.setState(StateSet.NOTHING);
}
}
else
{
drawable = view.getBackground();
if (drawable != null)
{
drawable.setState(StateSet.NOTHING);
drawable.jumpToCurrentState();
}
}
}
@SuppressLint("NewApi")
public static void clearDrawableAnimation(View view)
{
if (Build.VERSION.SDK_INT < 21 || view == null)
{
return;
}
Drawable drawable;
if (view instanceof ListView)
{
drawable = ((ListView) view).getSelector();
if (drawable != null)
{
drawable.setState(StateSet.NOTHING);
}
}
else
{
drawable = view.getBackground();
if (drawable != null)
{
drawable.setState(StateSet.NOTHING);
drawable.jumpToCurrentState();
}
}
}
private static void clearDrawableAnimation(View view) {
if (view == null) {
return;
}
Drawable drawable = null;
if (view instanceof ListView) {
drawable = ((ListView) view).getSelector();
if (drawable != null) {
drawable.setState(StateSet.NOTHING);
}
} else {
drawable = view.getBackground();
if (drawable != null) {
drawable.setState(StateSet.NOTHING);
drawable.jumpToCurrentState();
}
}
}
@SuppressLint("NewApi")
public static void clearDrawableAnimation(View view) {
if (Build.VERSION.SDK_INT < 21 || view == null) {
return;
}
Drawable drawable;
if (view instanceof ListView) {
drawable = ((ListView) view).getSelector();
if (drawable != null) {
drawable.setState(StateSet.NOTHING);
}
} else {
drawable = view.getBackground();
if (drawable != null) {
drawable.setState(StateSet.NOTHING);
drawable.jumpToCurrentState();
}
}
}
@SuppressLint("NewApi")
public static void clearDrawableAnimation(View view) {
if (Build.VERSION.SDK_INT < 21 || view == null) {
return;
}
Drawable drawable;
if (view instanceof ListView) {
drawable = ((ListView) view).getSelector();
if (drawable != null) {
drawable.setState(StateSet.NOTHING);
}
} else {
drawable = view.getBackground();
if (drawable != null) {
drawable.setState(StateSet.NOTHING);
drawable.jumpToCurrentState();
}
}
}
public void setOrAnimatePlusCheckIcon(final ImageView imageView, boolean isCheck,
boolean allowAnimate) {
if (!hasL()) {
compatSetOrAnimatePlusCheckIcon(imageView, isCheck, allowAnimate);
return;
}
Drawable drawable = imageView.getDrawable();
if (!(drawable instanceof AnimatedStateListDrawable)) {
drawable = mActivity.getResources().getDrawable(R.drawable.add_schedule_fab_icon_anim);
imageView.setImageDrawable(drawable);
}
imageView.setColorFilter(isCheck ?
mActivity.getResources().getColor(R.color.theme_accent_1) : Color.WHITE);
if (allowAnimate) {
imageView.setImageState(isCheck ? STATE_UNCHECKED : STATE_CHECKED, false);
drawable.jumpToCurrentState();
imageView.setImageState(isCheck ? STATE_CHECKED : STATE_UNCHECKED, false);
} else {
imageView.setImageState(isCheck ? STATE_CHECKED : STATE_UNCHECKED, false);
drawable.jumpToCurrentState();
}
}
@SuppressLint("NewApi")
public static void clearDrawableAnimation(View view) {
if (Build.VERSION.SDK_INT < 21 || view == null) {
return;
}
Drawable drawable;
if (view instanceof ListView) {
drawable = ((ListView) view).getSelector();
if (drawable != null) {
drawable.setState(StateSet.NOTHING);
}
} else {
drawable = view.getBackground();
if (drawable != null) {
drawable.setState(StateSet.NOTHING);
drawable.jumpToCurrentState();
}
}
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
if (ThemeUtils.isSkipAnimatedSelector()) {
Drawable drawable = CompoundButtonCompat.getButtonDrawable(this);
try {
if (ThemeUtils.getWrapperDrawable(drawable) instanceof AnimatedStateListDrawable) {
drawable.jumpToCurrentState();
}
} catch (NoClassDefFoundError error) {
error.printStackTrace();
}
}
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
if (ThemeUtils.isSkipAnimatedSelector()) {
Drawable drawable = CompoundButtonCompat.getButtonDrawable(this);
try {
if (ThemeUtils.getWrapperDrawable(drawable) instanceof AnimatedStateListDrawable) {
drawable.jumpToCurrentState();
}
} catch (NoClassDefFoundError error) {
error.printStackTrace();
}
}
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
if (ThemeUtils.isSkipAnimatedSelector()) {
Drawable drawable = CompoundButtonCompat.getButtonDrawable(this);
try {
if (ThemeUtils.getWrapperDrawable(drawable) instanceof AnimatedStateListDrawable) {
drawable.jumpToCurrentState();
}
} catch (NoClassDefFoundError error) {
error.printStackTrace();
}
}
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
if (ThemeUtils.isSkipAnimatedSelector()) {
Drawable drawable = CompoundButtonCompat.getButtonDrawable(this);
try {
if (ThemeUtils.getWrapperDrawable(drawable) instanceof AnimatedStateListDrawable) {
drawable.jumpToCurrentState();
}
} catch (NoClassDefFoundError error) {
error.printStackTrace();
}
}
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
if (ThemeUtils.isSkipAnimatedSelector()) {
Drawable drawable = CompoundButtonCompat.getButtonDrawable(this);
try {
if (ThemeUtils.getWrapperDrawable(drawable) instanceof AnimatedStateListDrawable) {
drawable.jumpToCurrentState();
}
} catch (NoClassDefFoundError error) {
error.printStackTrace();
}
}
}
/**
* Binds the {@code holder} according to its selected state using
* {@link View#setActivated(boolean)}.
*
* @param jumpToCurrentState When set, the background will have its {@link
* Drawable#jumpToCurrentState()} called. In general, this should be
* true for full binds, and false for partial binds that contain
* {@link #PAYLOAD_SELECT}.
*/
public boolean bind(@NonNull RecyclerView.ViewHolder holder, boolean jumpToCurrentState) {
boolean isSelected = isSelected(holder.getItemId());
holder.itemView.setActivated(isSelected);
if (jumpToCurrentState) {
// Ensure background jumps immediately to the current state.
Drawable background = holder.itemView.getBackground();
if (background != null) {
background.jumpToCurrentState();
}
}
return isSelected;
}
@Override
public void jumpToCurrentState(Drawable indeterminateDrawable) {
indeterminateDrawable.jumpToCurrentState();
}
public static void a(Drawable drawable)
{
drawable.jumpToCurrentState();
}
public static void jumpToCurrentState(Drawable drawable) {
drawable.jumpToCurrentState();
}
public static void jumpToCurrentState(Drawable drawable) {
drawable.jumpToCurrentState();
}
public static void jumpToCurrentState(Drawable drawable) {
drawable.jumpToCurrentState();
}
public static void jumpToCurrentState(Drawable drawable) {
drawable.jumpToCurrentState();
}