微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.graphics.drawable.AnimatedStateListDrawable的实例源码

@H_404_0@ 项目:iosched-reader    文件LUtils.java   
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();
    }
}
@H_404_0@ 项目:smconf-android    文件LUtils.java   
public void setorAnimatePlusCheckIcon(final FloatingActionButton fab,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();
    }
}
@H_404_0@ 项目:2015-Google-I-O-app    文件LUtils.java   
public void setorAnimatePlusCheckIcon(final FloatingActionButton fab,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();
    }
}
@H_404_0@ 项目:smoothnovelreader    文件LUtils.java   
public static void setorAnimatePlusCheckIcon(final Context context,final FloatingActionButton imageView,boolean allowAnimate) {
    if (!hasL()) {
        compatSetorAnimatePlusCheckIcon(context,imageView,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();
    }
}
@H_404_0@ 项目:FMTech    文件LUtils.java   
public void setorAnimatePlusCheckIcon(final FloatingActionButton fab,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();
    }
}
@H_404_0@ 项目:saarang-iosched    文件LUtils.java   
public void setorAnimatePlusCheckIcon(final ImageView imageView,boolean allowAnimate) {
    if (!hasL()) {
        compatSetorAnimatePlusCheckIcon(imageView,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();
    }
}
@H_404_0@ 项目:AppDevFestSudeste2015    文件LUtils.java   
public void setorAnimatePlusCheckIcon(final ImageView imageView,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();
    }
}
@H_404_0@ 项目:JJCamera    文件LUtils.java   
public void setorAnimatePlusCheckIcon(final FloatingActionButton fab,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();
    }
}
@H_404_0@ 项目:devfestnorte-app    文件LPreviewUtilsImpl.java   
@Override
public void setorAnimatePlusCheckIcon(final ImageView imageView,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();
    }
}
@H_404_0@ 项目:Orpheus    文件ControlsScreenView.java   
@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,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,R.drawable.vector_repeat_off_on_black_36dp),true);
    repeatDrawable.addTransition(R.id.repeat_on_state,R.id.repeat_one_state,R.drawable.vector_repeat_on_one_black_36dp),true);
    repeatDrawable.addTransition(R.id.repeat_one_state,R.id.repeat_off_state,R.drawable.vector_repeat_one_off_black_36dp),true);
    repeatDrawable.addTransition(R.id.repeat_off_state,R.drawable.vector_repeat_off_one_black_36dp),true);
            */
}
@H_404_0@ 项目:v2ex    文件LUtils.java   
public void setorAnimatePlusCheckIcon(final ImageView imageView,false);
        drawable.jumpToCurrentState();
    }
}
@H_404_0@ 项目:MagicaSakura    文件TinTradioButton.java   
@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();
        }
    }
}
@H_404_0@ 项目:MagicaSakura    文件TintCheckBox.java   
@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();
        }
    }
}
@H_404_0@ 项目:MagicaSakura    文件TintSwitchCompat.java   
@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();
        }
    }
}
@H_404_0@ 项目:Orpheus    文件FooterPageScreenView.java   
@TargetApi(21)
void setupDrawables21() {
    AnimatedStateListDrawable drawable = (AnimatedStateListDrawable) mPlayPause.getDrawable();
    drawable.addTransition(R.id.pause_state,false);
}
@H_404_0@ 项目:Orpheus    文件NowPlayingScreenView.java   
@TargetApi(21)
void setupDrawables21() {
    AnimatedStateListDrawable drawable = (AnimatedStateListDrawable) playPause.getDrawable();
    drawable.addTransition(R.id.pause_state,R.drawable.vector_pause_play_white_48dp),R.drawable.vector_play_pause_white_48dp),false);
}
@H_404_0@ 项目:XGPM    文件NowPlaying.java   
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",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","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",GPM));
            playPause.getBackground().setColorFilter(lastColor,PorterDuff.Mode.SRC_ATOP);
        }
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。