Java Code Examples for android.graphics.drawable.Drawable#jumpToCurrentState()

The following examples show how to use android.graphics.drawable.Drawable#jumpToCurrentState() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AndroidUtilities.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@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();
        }
    }
}
 
Example 2
Source File: LUtils.java    From v2ex with Apache License 2.0 6 votes vote down vote up
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();
    }
}
 
Example 3
Source File: AndroidUtilities.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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();
        }
    }
}
 
Example 4
Source File: DirectoryFragment.java    From SSForms with GNU General Public License v3.0 6 votes vote down vote up
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();
        }
    }
}
 
Example 5
Source File: AndroidUtilities.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@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();
        }
    }
}
 
Example 6
Source File: AndroidUtilities.java    From KrGallery with GNU General Public License v2.0 6 votes vote down vote up
@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();
        }
    }
}
 
Example 7
Source File: AndroidUtilities.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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();
        }
    }
}
 
Example 8
Source File: TintSwitchCompat.java    From MagicaSakura with Apache License 2.0 5 votes vote down vote up
@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();
        }
    }
}
 
Example 9
Source File: Selector.java    From RecyclerViewExtensions with MIT License 5 votes vote down vote up
/**
 * 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;
}
 
Example 10
Source File: TintCheckBox.java    From MagicaSakura with Apache License 2.0 5 votes vote down vote up
@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();
        }
    }
}
 
Example 11
Source File: TintRadioButton.java    From MagicaSakura with Apache License 2.0 5 votes vote down vote up
@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();
        }
    }
}
 
Example 12
Source File: TintCheckBox.java    From timecat with Apache License 2.0 5 votes vote down vote up
@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();
        }
    }
}
 
Example 13
Source File: TintRadioButton.java    From timecat with Apache License 2.0 5 votes vote down vote up
@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();
        }
    }
}
 
Example 14
Source File: d.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public static void a(Drawable drawable)
{
    drawable.jumpToCurrentState();
}
 
Example 15
Source File: DrawableCompatHoneycomb.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public static void jumpToCurrentState(Drawable drawable) {
    drawable.jumpToCurrentState();
}
 
Example 16
Source File: DrawableCompatHoneycomb.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
public static void jumpToCurrentState(Drawable drawable) {
    drawable.jumpToCurrentState();
}
 
Example 17
Source File: DrawableCompatHoneycomb.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
public static void jumpToCurrentState(Drawable drawable) {
    drawable.jumpToCurrentState();
}
 
Example 18
Source File: Utility11.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void jumpToCurrentState(Drawable indeterminateDrawable) {
    indeterminateDrawable.jumpToCurrentState();
}
 
Example 19
Source File: DrawableCompatHoneycomb.java    From guideshow with MIT License 4 votes vote down vote up
public static void jumpToCurrentState(Drawable drawable) {
    drawable.jumpToCurrentState();
}