本文整理汇总了Java中android.graphics.drawable.AnimatedStateListDrawable类的典型用法代码示例。如果您正苦于以下问题:Java AnimatedStateListDrawable类的具体用法?Java AnimatedStateListDrawable怎么用?Java AnimatedStateListDrawable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnimatedStateListDrawable类属于android.graphics.drawable包,在下文中一共展示了AnimatedStateListDrawable类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setOrAnimatePlusCheckIcon
import android.graphics.drawable.AnimatedStateListDrawable; //导入依赖的package包/类
public void setOrAnimatePlusCheckIcon(final FloatingActionButton fab, boolean isCheck,
boolean allowAnimate) {
if (!hasL()) {
compatSetOrAnimatePlusCheckIcon(fab, isCheck, allowAnimate);
return;
}
Drawable drawable = fab.getDrawable();
if (!(drawable instanceof AnimatedStateListDrawable)) {
Resources res = mActivity.getResources();
drawable = res.getDrawable(R.drawable.add_schedule_fab_icon_anim);
drawable.setTint(res.getColor(R.color.fab_icon_color));
fab.setImageDrawable(drawable);
}
if (allowAnimate) {
drawable.setState(isCheck ? STATE_UNCHECKED : STATE_CHECKED);
drawable.jumpToCurrentState();
drawable.setState(isCheck ? STATE_CHECKED : STATE_UNCHECKED);
} else {
drawable.setState(isCheck ? STATE_CHECKED : STATE_UNCHECKED);
drawable.jumpToCurrentState();
}
}
示例2: setOrAnimatePlusCheckIcon
import android.graphics.drawable.AnimatedStateListDrawable; //导入依赖的package包/类
public static void setOrAnimatePlusCheckIcon(final Context context, final FloatingActionButton imageView, boolean isCheck,
boolean allowAnimate) {
if (!hasL()) {
compatSetOrAnimatePlusCheckIcon(context, imageView, isCheck, allowAnimate);
return;
}
Drawable drawable = imageView.getDrawable();
if (!(drawable instanceof AnimatedStateListDrawable)) {
drawable = ResourcesCompat.getDrawable(
context.getResources(),
R.drawable.add_schedule_fab_icon_anim,
null
);
imageView.setImageDrawable(drawable);
}
imageView.setColorFilter(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();
}
}
示例3: setOrAnimatePlusCheckIcon
import android.graphics.drawable.AnimatedStateListDrawable; //导入依赖的package包/类
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(com.saarang.samples.apps.iosched.R.drawable.add_schedule_fab_icon_anim);
imageView.setImageDrawable(drawable);
}
imageView.setColorFilter(isCheck ?
mActivity.getResources().getColor(com.saarang.samples.apps.iosched.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();
}
}
示例4: setOrAnimatePlusCheckIcon
import android.graphics.drawable.AnimatedStateListDrawable; //导入依赖的package包/类
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();
}
}
示例5: setOrAnimatePlusCheckIcon
import android.graphics.drawable.AnimatedStateListDrawable; //导入依赖的package包/类
@Override
public void setOrAnimatePlusCheckIcon(final ImageView imageView, boolean isCheck,
boolean allowAnimate) {
AnimatedStateListDrawable drawable = (AnimatedStateListDrawable)
mActivity.getResources().getDrawable(R.drawable.add_schedule_fab_icon_anim);
imageView.setImageDrawable(drawable);
if (allowAnimate) {
// TODO: figure out if there's a way to always animate from current state
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();
}
}
示例6: setupDrawables21
import android.graphics.drawable.AnimatedStateListDrawable; //导入依赖的package包/类
@TargetApi(21)
void setupDrawables21() {
//add state transitions
AnimatedStateListDrawable drawable = (AnimatedStateListDrawable) play.getDrawable();
drawable.addTransition(R.id.pause_state, R.id.play_state, (AnimatedVectorDrawable)
ContextCompat.getDrawable(getContext(), R.drawable.vector_pause_play_black_36dp), false);
drawable.addTransition(R.id.play_state, R.id.pause_state, (AnimatedVectorDrawable)
ContextCompat.getDrawable(getContext(), R.drawable.vector_play_pause_black_36dp), false);
/*
AnimatedStateListDrawable repeatDrawable = (AnimatedStateListDrawable) repeat.getDrawable();
repeatDrawable.addTransition(R.id.repeat_off_state, R.id.repeat_on_state, (AnimatedVectorDrawable)
ContextCompat.getDrawable(getContext(), R.drawable.vector_repeat_off_on_black_36dp), true);
repeatDrawable.addTransition(R.id.repeat_on_state, R.id.repeat_one_state, (AnimatedVectorDrawable)
ContextCompat.getDrawable(getContext(), R.drawable.vector_repeat_on_one_black_36dp), true);
repeatDrawable.addTransition(R.id.repeat_one_state, R.id.repeat_off_state, (AnimatedVectorDrawable)
ContextCompat.getDrawable(getContext(), R.drawable.vector_repeat_one_off_black_36dp), true);
repeatDrawable.addTransition(R.id.repeat_off_state, R.id.repeat_one_state, (AnimatedVectorDrawable)
ContextCompat.getDrawable(getContext(), R.drawable.vector_repeat_off_one_black_36dp), true);
*/
}
示例7: drawableStateChanged
import android.graphics.drawable.AnimatedStateListDrawable; //导入依赖的package包/类
@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();
}
}
}
示例8: setupDrawables21
import android.graphics.drawable.AnimatedStateListDrawable; //导入依赖的package包/类
@TargetApi(21)
void setupDrawables21() {
AnimatedStateListDrawable drawable = (AnimatedStateListDrawable) mPlayPause.getDrawable();
drawable.addTransition(R.id.pause_state, R.id.play_state, (AnimatedVectorDrawable)
ContextCompat.getDrawable(getContext(), R.drawable.vector_pause_play_black_36dp), false);
drawable.addTransition(R.id.play_state, R.id.pause_state, (AnimatedVectorDrawable)
ContextCompat.getDrawable(getContext(), R.drawable.vector_play_pause_black_36dp), false);
}
示例9: setupDrawables21
import android.graphics.drawable.AnimatedStateListDrawable; //导入依赖的package包/类
@TargetApi(21)
void setupDrawables21() {
AnimatedStateListDrawable drawable = (AnimatedStateListDrawable) playPause.getDrawable();
drawable.addTransition(R.id.pause_state, R.id.play_state, (AnimatedVectorDrawable)
ContextCompat.getDrawable(getContext(), R.drawable.vector_pause_play_white_48dp), false);
drawable.addTransition(R.id.play_state, R.id.pause_state, (AnimatedVectorDrawable)
ContextCompat.getDrawable(getContext(), R.drawable.vector_play_pause_white_48dp), false);
}
示例10: updateTint
import android.graphics.drawable.AnimatedStateListDrawable; //导入依赖的package包/类
private static void updateTint(final Object nowPlayingFragment) throws Throwable {
if (PREFS.getBoolean(Common.NP_TINT_ICONS, false)) {
ViewGroup root = (ViewGroup) getObjectField(nowPlayingFragment, "mRootView");
Object currentState = getObjectField(nowPlayingFragment, "mCurrentState");
Class exStateClass = findClass(EXPANDING_STATE, nowPlayingFragment.getClass().getClassLoader());
if (currentState == Enum.valueOf(exStateClass, "FULLY_EXPANDED")) {
Object artPager = getObjectField(nowPlayingFragment, "mArtPager");
ArrayList<?> mItems = (ArrayList<?>) getObjectField(artPager, "mItems");
Object artPageFragment = null;
for (int i = 0; i < mItems.size(); i++) {
if (getIntField(mItems.get(i), "position") == (int) callMethod(artPager, "getCurrentItem")) {
artPageFragment = getObjectField(mItems.get(i), "object");
break;
}
}
// Update color
if (artPageFragment != null) {
ImageView mAlbum = (ImageView) getObjectField(artPageFragment, "mAlbum");
if (mAlbum.getDrawable() != null) {
Palette coverPalette = Palette.from(((BitmapDrawable) mAlbum.getDrawable()).getBitmap()).maximumColorCount(16).generate();
lastColor = coverPalette.getVibrantColor(Color.parseColor("#9E9E9E"));
} else {
((Handler) getObjectField(nowPlayingFragment, "mHandler")).postDelayed(new Runnable() {
@Override
public void run() {
try {
updateTint(nowPlayingFragment);
} catch (Throwable t) {
log(t);
}
}
}, 200);
return;
}
}
if (isNewDesignEnabled()) {
// Tint header bar & its items
RelativeLayout customHeaderBar = (RelativeLayout) root.findViewById(modRes.getIdentifier("header_bar", "id", XGPM));
if (customHeaderBar != null) {
customHeaderBar.setBackgroundColor(lastColor);
RelativeLayout wrapper = (RelativeLayout) customHeaderBar.getChildAt(0);
double contrastBlack = ColorUtils.calculateContrast(Color.BLACK, lastColor);
double contrastWhite = ColorUtils.calculateContrast(Color.WHITE, lastColor);
int imageColor = contrastBlack > contrastWhite ? Color.BLACK : Color.WHITE;
for (int j = 0; j < wrapper.getChildCount(); j++) {
View current = wrapper.getChildAt(j);
if (current instanceof ImageView && current.getId() != root.getResources().getIdentifier("play_pause_header", "id", GPM)) {
((ImageView) current).setColorFilter(imageColor);
} else if (current instanceof FrameLayout && ((FrameLayout) current).getChildCount() > 0 &&
((FrameLayout) current).getChildAt(0).getClass().getSimpleName().equals("MediaRouteButton")) {
((Drawable) getObjectField(((FrameLayout) current).getChildAt(0), "mRemoteIndicator")).setColorFilter(imageColor, PorterDuff.Mode.SRC_ATOP);
}
}
}
} else {
tintQueueButton(nowPlayingFragment);
}
// Tint all the rest
for (Object pager : new Object[]{getObjectField(nowPlayingFragment, "mHeaderPager"), artPager}) {
if (pager == null)
continue;
for (Object edgeEffectCompat : new Object[]{getObjectField(pager, "mLeftEdge"), getObjectField(pager, "mRightEdge")}) {
((Paint) getObjectField(getObjectField(edgeEffectCompat, "mEdgeEffect"), "mPaint")).setColor(lastColor);
}
}
SeekBar seekBar = (SeekBar) getObjectField(nowPlayingFragment, "mProgress");
LayerDrawable progress = (LayerDrawable) seekBar.getProgressDrawable().getCurrent();
ClipDrawable clipProgress = (ClipDrawable) progress.findDrawableByLayerId(root.getResources().getIdentifier("progress", "id", "android"));
clipProgress.setColorFilter(lastColor, PorterDuff.Mode.SRC_IN);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
AnimatedStateListDrawable thumb = (AnimatedStateListDrawable) seekBar.getThumb();
thumb.setColorFilter(lastColor, PorterDuff.Mode.SRC_IN);
}
ImageButton playPause = (ImageButton) root.findViewById(root.getResources().getIdentifier("pause", "id", GPM));
playPause.getBackground().setColorFilter(lastColor, PorterDuff.Mode.SRC_ATOP);
}
}
}