Java 类android.graphics.drawable.LevelListDrawable 实例源码

项目:chromium-for-android-56-debug-video    文件:RecentTabsGroupView.java   
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mDeviceIcon = (ImageView) findViewById(R.id.device_icon);
    mTimeLabel = (TextView) findViewById(R.id.time_label);
    mDeviceLabel = (TextView) findViewById(R.id.device_label);
    mExpandCollapseIcon = (ImageView) findViewById(R.id.expand_collapse_icon);

    // Create drawable for expand/collapse arrow.
    LevelListDrawable collapseIcon = new LevelListDrawable();
    collapseIcon.addLevel(DRAWABLE_LEVEL_COLLAPSED, DRAWABLE_LEVEL_COLLAPSED,
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_expanded));
    TintedDrawable collapse =
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_collapsed);
    collapse.setTint(
            ApiCompatibilityUtils.getColorStateList(getResources(), R.color.blue_mode_tint));
    collapseIcon.addLevel(DRAWABLE_LEVEL_EXPANDED, DRAWABLE_LEVEL_EXPANDED, collapse);
    mExpandCollapseIcon.setImageDrawable(collapseIcon);
}
项目:target-layout    文件:TargetLayout.java   
private void init(Context context, AttributeSet attrs) {

        setWillNotDraw(false);
        if (attrs != null) {
            TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TargetLayout);
            centerPercent = ta.getFloat(R.styleable.TargetLayout_center_percent, DEFAULT_CENTER_PERCENT);
            stepPercent = ta.getFloat(R.styleable.TargetLayout_step_percent, DEFAULT_STEP_PERCENT);
            maxNumberOfLevels = ta.getInteger(R.styleable.TargetLayout_max_number_of_levels, DEFAULT_MAX_NUMBER_OF_LEVELS);
            try {
                levelListDrawable = (LevelListDrawable) ta.getDrawable(R.styleable.TargetLayout_levelDrawable);
            } catch (ClassCastException e) {
                throw new IllegalArgumentException("a LevelListDrawable must be passed");
            }
            updateTarget();
            ta.recycle();
        }

        ScaleListener scaleListener = new ScaleListener();
        scaleGestureDetector = new ScaleGestureDetector(context, scaleListener);
    }
项目:home-assistant-Android    文件:SwitchViewHolder.java   
private void updateColor() {
    Drawable leftDrawable = name.getCompoundDrawablesRelative()[0];
    String domain = entity.getDomain();
    if (leftDrawable != null && (domain.equals(LIGHT) || domain.equals(SWITCH))) {
        if (!(leftDrawable instanceof LevelListDrawable)) {
            LevelListDrawable levelListDrawable = new LevelListDrawable();
            // Add states
            levelListDrawable.addLevel(1, 1, leftDrawable);
            BitmapDrawable enabledDrawable = (BitmapDrawable) leftDrawable.getConstantState().newDrawable().mutate();
            enabledDrawable.setTintList(ColorStateList.valueOf(ContextCompat.getColor(name.getContext(), R.color.color_activated)));
            levelListDrawable.addLevel(2, 2, enabledDrawable);
            // Restore bounds
            levelListDrawable.setBounds(0, 0, name.getResources().getDimensionPixelSize(R.dimen.icon_size), name.getResources().getDimensionPixelSize(R.dimen.icon_size));

            // Set drawable
            name.setCompoundDrawablesRelative(levelListDrawable, null, null, null);
            leftDrawable = levelListDrawable;
        }
        leftDrawable.setLevel(entity.state.equals(HassUtils.getOnState(entity, false)) ? 1 : 2);
    }
}
项目:ROKO.Stickers-Android    文件:LevelListImageFetchTask.java   
@Override
public Drawable loadFromMemCache(ImageCache cache, Resources res) {
    if(cache == null)
        return null;
    LevelListDrawable sld = new LevelListDrawable();
    for (int i = 0; i < urls.size(); i++) {
        Bitmap bmp = cache.getBitmapFromMemCache(getStoreKey(i));
        if (mCachePolicy == CachePolicy.NO_CACHE)
            cache.removeBitmapFromCache(getStoreKey(i));
        if (bmp == null)
            return null;
        sld.addLevel(levels.get(i)[0], levels.get(i)[1],
                new BitmapDrawable(res, bmp));
    }
    return sld;
}
项目:target-layout    文件:TargetLayout.java   
private void init(Context context, AttributeSet attrs) {

        setWillNotDraw(false);
        if (attrs != null) {
            TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TargetLayout);
            centerPercent = ta.getFloat(R.styleable.TargetLayout_center_percent, DEFAULT_CENTER_PERCENT);
            stepPercent = ta.getFloat(R.styleable.TargetLayout_step_percent, DEFAULT_STEP_PERCENT);
            maxNumberOfLevels = ta.getInteger(R.styleable.TargetLayout_max_number_of_levels, DEFAULT_MAX_NUMBER_OF_LEVELS);
            try {
                levelListDrawable = (LevelListDrawable) ta.getDrawable(R.styleable.TargetLayout_levelDrawable);
            } catch (ClassCastException e) {
                throw new IllegalArgumentException("a LevelListDrawable must be passed");
            }
            updateTarget();
            ta.recycle();
        }

        ScaleListener scaleListener = new ScaleListener();
        scaleGestureDetector = new ScaleGestureDetector(context, scaleListener);
    }
项目:AndroidChromium    文件:RecentTabsGroupView.java   
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mDeviceIcon = (ImageView) findViewById(R.id.device_icon);
    mTimeLabel = (TextView) findViewById(R.id.time_label);
    mDeviceLabel = (TextView) findViewById(R.id.device_label);
    mExpandCollapseIcon = (ImageView) findViewById(R.id.expand_collapse_icon);

    // Create drawable for expand/collapse arrow.
    LevelListDrawable collapseIcon = new LevelListDrawable();
    collapseIcon.addLevel(DRAWABLE_LEVEL_COLLAPSED, DRAWABLE_LEVEL_COLLAPSED,
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_expanded));
    TintedDrawable collapse =
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_collapsed);
    collapse.setTint(
            ApiCompatibilityUtils.getColorStateList(getResources(), R.color.blue_mode_tint));
    collapseIcon.addLevel(DRAWABLE_LEVEL_EXPANDED, DRAWABLE_LEVEL_EXPANDED, collapse);
    mExpandCollapseIcon.setImageDrawable(collapseIcon);
}
项目:Vafrinn    文件:RecentTabsGroupView.java   
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mDeviceIcon = (ImageView) findViewById(R.id.device_icon);
    mTimeLabel = (TextView) findViewById(R.id.time_label);
    mDeviceLabel = (TextView) findViewById(R.id.device_label);
    mExpandCollapseIcon = (ImageView) findViewById(R.id.expand_collapse_icon);

    // Create drawable for expand/collapse arrow.
    LevelListDrawable collapseIcon = new LevelListDrawable();
    collapseIcon.addLevel(DRAWABLE_LEVEL_COLLAPSED, DRAWABLE_LEVEL_COLLAPSED,
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_expand));
    TintedDrawable collapse =
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_collapse);
    collapse.setTint(getResources().getColorStateList(R.color.blue_mode_tint));
    collapseIcon.addLevel(DRAWABLE_LEVEL_EXPANDED, DRAWABLE_LEVEL_EXPANDED, collapse);
    mExpandCollapseIcon.setImageDrawable(collapseIcon);
}
项目:365browser    文件:RecentTabsGroupView.java   
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mDeviceIcon = (ImageView) findViewById(R.id.device_icon);
    mTimeLabel = (TextView) findViewById(R.id.time_label);
    mDeviceLabel = (TextView) findViewById(R.id.device_label);
    mExpandCollapseIcon = (ImageView) findViewById(R.id.expand_collapse_icon);

    // Create drawable for expand/collapse arrow.
    LevelListDrawable collapseIcon = new LevelListDrawable();
    collapseIcon.addLevel(DRAWABLE_LEVEL_COLLAPSED, DRAWABLE_LEVEL_COLLAPSED,
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_expanded));
    TintedDrawable collapse =
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_collapsed);
    collapse.setTint(
            ApiCompatibilityUtils.getColorStateList(getResources(), R.color.blue_mode_tint));
    collapseIcon.addLevel(DRAWABLE_LEVEL_EXPANDED, DRAWABLE_LEVEL_EXPANDED, collapse);
    mExpandCollapseIcon.setImageDrawable(collapseIcon);
}
项目:NinePatchBuildUtils    文件:LevelListExampleActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_level_example);

    Resources resources = getResources();

    NinePatchBuilder ninePatchBuilder = new NinePatchBuilder(resources)
        .addStretchSegmentX(0.65f, 0.66f)
        .addStretchSegmentY(0.45f, 0.46f)
        .setDrawable(R.drawable.vector_level_list,
                (int) resources.getDimension(R.dimen.vector_border_width),
                (int) resources.getDimension(R.dimen.vector_border_height));

    mBuilderDrawable = (LevelListDrawable) ninePatchBuilder.build();
    findViewById(R.id.builder).setBackground(mBuilderDrawable);

    mInflaterDrawable = (LevelListDrawable) NinePatchInflater.inflate(resources, R.xml.vector_level_list_nine_patch);
    findViewById(R.id.inflater).setBackground(mInflaterDrawable);
}
项目:itsnat_droid    文件:Assert.java   
public static void assertEquals(LevelListDrawable a,LevelListDrawable b)
{
    assertEqualsDrawableContainer( a, b);

    assertEquals(a.getLevel(),b.getLevel());

    Drawable.ConstantState a_state = a.getConstantState();
    Drawable.ConstantState b_state = b.getConstantState();

    Class classState = TestUtil.resolveClass(LevelListDrawable.class.getName() + "$LevelListState");

    int[] a_lows = (int[])TestUtil.getField(a_state, classState, "mLows");
    int[] b_lows = (int[])TestUtil.getField(b_state, classState, "mLows");
    assertEquals(a_lows.length,b_lows.length);
    for(int i = 0; i < a_lows.length; i++)
        assertEquals(a_lows[i],b_lows[i]);

    int[] a_highs = (int[])TestUtil.getField(a_state, classState, "mHighs");
    int[] b_highs = (int[])TestUtil.getField(b_state, classState, "mHighs");
    assertEquals(a_highs.length,b_highs.length);
    for(int i = 0; i < a_highs.length; i++)
        assertEquals(a_highs[i],b_highs[i]);

}
项目:LiteReader    文件:RichTextView.java   
@Override
public Drawable getDrawable(String source) {
    final RichTextView tv = weakRef.get();
    final LevelListDrawable mDrawable = new LevelListDrawable();

    Glide.with(tv.getContext()).load(source).asBitmap().placeholder(R.drawable.ic_placeholder).into(new SimpleTarget<Bitmap>() {
        @Override
        public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
            if (width == 0) {
                tv.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                width = tv.getWidth();
            }
            BitmapDrawable d = new BitmapDrawable(resource);
            mDrawable.addLevel(1, 1, d);
            int imageWidth;
            int imageHeight;
            //小图只需略微扩大,大图则宽度铺满
            if (resource.getHeight() < 50 || resource.getWidth() < 50) {
                imageWidth = (int) (resource.getWidth() * zoomFactor);
                imageHeight = (int) (resource.getHeight() * zoomFactor);
            } else {
                imageWidth = width;
                double ratio = (double) resource.getHeight() / (double) resource.getWidth();
                imageHeight = (int) (ratio * width);
            }
            mDrawable.setBounds(0, 0, imageWidth, imageHeight);
            mDrawable.setLevel(1);
            tv.invalidate();
            tv.setText(tv.getText());
        }
    });
    return mDrawable;
}
项目:AssistantBySDK    文件:RspMsgItemView.java   
protected void init(Context mContext) {
    LayoutInflater iflater = LayoutInflater.from(mContext);
    iflater.inflate(R.layout.common_bubble_dialog_left, this);
    mTextView = (TextView) findViewById(R.id.common_bubble_left_text);
    mTextView.setOnTouchListener(this);
    mListDrawable = (LevelListDrawable) mTextView.getBackground();
}
项目:AssistantBySDK    文件:ChooseSetPopupWindow.java   
@Override
public void onBindViewHolder(ChooseSetAdapter.SetHolder holder, int position) {
    int page = position + 1;
    LevelListDrawable ld = (LevelListDrawable) holder.mTvSetCount.getBackground();
    if (page == currentPage) {
        ld.setLevel(1);
        holder.mTvSetCount.setTextColor(mContext.getResources().getColor(R.color.white));
    } else {
        ld.setLevel(0);
        holder.mTvSetCount.setTextColor(mContext.getResources().getColor(R.color.new_text_color_first));
    }
    setText(holder.mTvSetCount, page);
}
项目:AssistantBySDK    文件:RealTimeUpdateSearchBox.java   
private void init(AttributeSet attrs, int defStyle) {
    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.lingju, defStyle, 0);
    LayoutInflater.from(getContext()).inflate(R.layout.search_online_box, this);
    mLlRoot = findViewById(R.id.ll_root);
    edit = (EditText) findViewById(R.id.sob_search_edit);
    stateBt = (ImageButton) findViewById(R.id.sob_state_bt);
    animate = AnimationUtils.loadAnimation(getContext(), R.anim.start_up_loading);
    animate.setInterpolator(new LinearInterpolator());
    drawable = (LevelListDrawable) stateBt.getDrawable();
    edit.addTextChangedListener(searhWatcher);
    edit.setOnEditorActionListener(editorActionListener);
    edit.setOnClickListener(editorClickListener);
    stateBt.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (stateBt.getVisibility() == View.VISIBLE && drawable.getLevel() == 1) {
                edit.setText("");
                stateBt.setVisibility(View.INVISIBLE);
            }
        }
    });
    edit.setHint(a.getString(R.styleable.lingju_hint));
    // edit.setHintTextColor(getResources().getColor(R.color.navi_search_box_color));
    edit.setHintTextColor(a.getColor(R.styleable.lingju_hintColor, getResources().getColor(R.color.navi_search_box_color)));
    edit.setTextColor(a.getColor(R.styleable.lingju_textColor, getResources().getColor(R.color.ksw_md_solid_disable)));
    mLlRoot.setBackgroundColor(a.getColor(R.styleable.lingju_search_background, getResources().getColor(R.color.green_style)));
    //edit.setTextSize(a.getFloat(com.android.internal.R.styleable.TextView_textSize,12));

    a.recycle();
}
项目:AssistantBySDK    文件:ChatListAdapter.java   
@OnClick({R.id.tv_subscribe, R.id.tv_choose_set, R.id.ll_play_track_box, R.id.iv_ting_switch})
public void onClick(View view) {
    TingAlbumMsg albumMsg = (TingAlbumMsg) datas.get(getAdapterPosition());
    Album album = albumMsg.getAlbums().get(0);
    switch (view.getId()) {
        case R.id.tv_subscribe:
            LevelListDrawable ld = (LevelListDrawable) mTvSubscribe.getBackground();
            if (ld.getLevel() == 0) {      //订阅
                ld.setLevel(1);
                mTvSubscribe.setText("已订阅");
                TingAlbumDao.getInstance().insertSubscribe(album);
            } else {
                ld.setLevel(0);
                mTvSubscribe.setText("订阅");
                TingAlbumDao.getInstance().delSubscribeById(album.getId());
            }
            break;
        case R.id.tv_choose_set:
            Intent intent = new Intent(mContext, TingAlbumDetailActivity.class);
            intent.putExtra(TingAlbumDetailActivity.ALBUM_ID, album.getId());
            int type = album.getCoverUrlMiddle().contains(TingPlayProcessor.KAOLA_FM) ? TingAlbumDetailActivity.KAOLA : TingAlbumDetailActivity.XIMALAYA;
            intent.putExtra(TingAlbumDetailActivity.ALBUM_TYPE, type);
            mContext.startActivity(intent);
            ((Activity) mContext).overridePendingTransition(R.anim.activity_start_in, R.anim.activity_start_out);
            break;
        case R.id.ll_play_track_box:
        case R.id.iv_ting_switch:
            boolean isPlaying = XmlyManager.get().isPlaying();
            if (isPlaying) {
                XmPlayerManager.getInstance(mContext).pause();
            } else {
                XmPlayerManager.getInstance(mContext).play();
            }
            break;
    }
}
项目:AssistantBySDK    文件:TrafficShowPresenter.java   
@Override
public Object instantiateItem(ViewGroup container, int position) {
    Log.i(TAG, "instantiateItem>>>" + position);
    View child = chilren.get(position);
    if (child == null) {
        child = inflater.inflate(R.layout.target_poi_item_detail, null);
        chilren.put(position, child);
    }
    child.findViewById(R.id.tpid_target_confirm_bt).setOnClickListener(clickListener);
    child.findViewById(R.id.tpid_target_confirm_bt).setTag(position);
    ((TextView) child.findViewById(R.id.tpid_name_text)).setText((position + 1) + "." + aList.get(position).getName());
    ((TextView) child.findViewById(R.id.tpid_address_text)).setText(aList.get(position).getAddress());
    Double distance = DistanceUtil.getDistance(new LatLng(address.getLatitude(), address.getLongitude()),
            poiInfoList.get(position).location) / 1000;
    ((TextView) child.findViewById(R.id.tpid_distance_text)).setText(String.format("%.1f", distance) + "km");
    child.findViewById(R.id.tpid_set_target_bt).setOnClickListener(clickListener);
    child.findViewById(R.id.tpid_set_target_bt).setTag(position);
    TextView ft = (TextView) child.findViewById(R.id.tpid_favorite_bt);
    ft.setOnClickListener(clickListener);
    ft.setTag(position);
    if (aList.get(position).getFavoritedTime() != null) {
        ft.setText("已收藏");
        ((LevelListDrawable) ft.getBackground()).setLevel(1);
    }
    container.addView(child, 0);
    return chilren.get(position);
}
项目:AssistantBySDK    文件:GuideActivity.java   
public void setDot(int position) {
    mBeginBt.setVisibility(View.GONE);
    for (int i = 0; i < mllDot.getChildCount(); i++) {
        View dotView = mllDot.getChildAt(i);
        LevelListDrawable ld = (LevelListDrawable) dotView.getBackground();
        ld.setLevel(position == i ? 1 : 0);
    }
}
项目:ROKO.Stickers-Android    文件:LevelListImageFetchTask.java   
@Override
public Drawable loadFromDiskCache(ImageCache cache, Resources res) {
    if(cache == null)
        return null;
    LevelListDrawable sld = new LevelListDrawable();
    for (int i = 0; i < urls.size(); i++) {
        Bitmap bmp = cache.getBitmapFromDiskCache(getStoreKey(i));
        if (bmp == null)
            return null;
        cache.addBitmapToCache(getStoreKey(i), bmp);
        sld.addLevel(levels.get(i)[0], levels.get(i)[1],
                new BitmapDrawable(res, bmp));
    }
    return sld;
}
项目:xowa_android    文件:AudioUrlSpan.java   
@NonNull
private static Drawable drawable(Context context) {
    LevelListDrawable levels = new AppLevelListDrawable();
    levels.addLevel(PLAY_ICON_LEVEL, PLAY_ICON_LEVEL, spinnerDrawable(context));
    levels.addLevel(STOP_ICON_LEVEL, STOP_ICON_LEVEL, speakerDrawable(context));
    int radius = getDimensionPixelSize(context, R.dimen.audio_url_span_loading_spinner_radius);
    levels.setBounds(0, 0, radius * 2, radius * 2);
    return levels;
}
项目:H-Viewer    文件:URLImageParser.java   
@Override
public Drawable getDrawable(String source) {
    Logger.d("URLImageParser", "source:" + source);
    final LevelListDrawable mDrawable = new LevelListDrawable();
    Drawable empty = new BitmapDrawable();
    mDrawable.addLevel(0, 0, empty);
    mDrawable.setBounds(0, 0, empty.getIntrinsicWidth(), empty.getIntrinsicHeight());
    // get the actual source
    ImageLoader.loadBitmapFromUrl(context, source, cookie, referer, new BaseBitmapDataSubscriber() {
        @Override
        protected void onNewResultImpl(Bitmap bitmap) {
            if (bitmap != null) {
                Bitmap copy = bitmap.copy(Bitmap.Config.ARGB_8888, true);
                Drawable drawable = new BitmapDrawable(context.getResources(), copy);
                mDrawable.addLevel(1, 1, drawable);
                mDrawable.setBounds(0, 0, copy.getWidth(), copy.getHeight());
                mDrawable.setLevel(1);
                new Handler(context.getMainLooper()).post(new Runnable() {
                    @Override
                    public void run() {
                        CharSequence t = textView.getText();
                        textView.setText(t);
                    }
                });
            }
        }

        @Override
        protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
        }
    });

    // return reference to URLDrawable where I will change with actual image from
    // the src tag
    return mDrawable;
}
项目:SIHSchool    文件:SNoticeDetail.java   
@Override
public Drawable getDrawable(String source) {
    LevelListDrawable d = new LevelListDrawable();
    Drawable empty = getResources().getDrawable(R.drawable.ic_launcher);
    d.addLevel(0, 0, empty);
    d.setBounds(0, 0, empty.getIntrinsicWidth(), empty.getIntrinsicHeight());

    new LoadImage().execute(source, d);

    return d;
}
项目:itsnat_droid    文件:ClassDescLevelListDrawable.java   
@Override
public ElementDrawableChildRoot createElementDrawableChildRoot(DOMElemDrawable rootElem, AttrDrawableContext attrCtx)
{
    ElementDrawableChildRoot elementDrawableRoot = new ElementDrawableChildRoot();

    XMLInflaterDrawable xmlInflaterDrawable = attrCtx.getXMLInflaterDrawable();
    xmlInflaterDrawable.processChildElements(rootElem,elementDrawableRoot,attrCtx);
    ArrayList<ElementDrawableChildBase> itemList = elementDrawableRoot.getElementDrawableChildList();

    LevelListDrawable drawable = new LevelListDrawable();

    for(int i = 0; i < itemList.size(); i++)
    {
        LevelListDrawableChildItem item = (LevelListDrawableChildItem)itemList.get(i);

        Drawable drawableChild = item.getDrawable();

        Integer minObj = item.getMinLevel();
        Integer maxObj = item.getMaxLevel();
        int min = minObj != null ? minObj : 0; // Según el código fuente
        int max = maxObj != null ? maxObj : 0; // Según el código fuente

        drawable.addLevel(min,max,drawableChild);

        setCallback(drawableChild,drawable); // Se puede ver en el código fuente si se sigue hasta addChild(Drawable dr)
    }

    elementDrawableRoot.setDrawable(drawable);

    return elementDrawableRoot;
}
项目:Orpheus    文件:PlaybackDrawableTint.java   
public static LevelListDrawable getShuffleDrawable36(Context context, int color) {
    final int res = R.drawable.ic_shuffle_white_36dp;
    final LevelListDrawable d = new LevelListDrawable();
    d.addLevel(0,0, context.getResources().getDrawable(res));
    d.addLevel(1, 2, tintDrawable(context, res, color));
    return d;
}
项目:Orpheus    文件:PlaybackDrawableTint.java   
public static LevelListDrawable getRepeatDrawable36(Context context, int color) {
    final int one = R.drawable.ic_repeat_once_white_36dp;
    final int all = R.drawable.ic_repeat_white_36dp;
    final LevelListDrawable d = new LevelListDrawable();
    d.addLevel(0, 0, context.getResources().getDrawable(all));
    d.addLevel(1, 1, tintDrawable(context, one, color));
    d.addLevel(2, 2, tintDrawable(context, all, color));
    return d;
}
项目:Orpheus    文件:PlaybackDrawableTint.java   
static void doRepeatDrawable(ImageButton v, boolean is24, int color) {
    int one = is24 ? R.drawable.ic_repeat_once_white_24dp : R.drawable.ic_repeat_once_white_36dp;
    int all = is24 ? R.drawable.ic_repeat_white_24dp : R.drawable.ic_repeat_white_36dp;
    LevelListDrawable d = (LevelListDrawable) v.getDrawable();
    d.addLevel(1, 1, tintDrawable(v.getContext(), one, color));
    d.addLevel(2, 2, tintDrawable(v.getContext(), all, color));
}
项目:Orpheus    文件:PlaybackDrawableTint.java   
public static LevelListDrawable getShuffleDrawable36(Context context, int color) {
    final int res = R.drawable.ic_shuffle_white_36dp;
    final LevelListDrawable d = new LevelListDrawable();
    d.addLevel(0,0, context.getResources().getDrawable(res));
    d.addLevel(1, 2, tintDrawable(context, res, color));
    return d;
}
项目:Orpheus    文件:PlaybackDrawableTint.java   
public static LevelListDrawable getRepeatDrawable36(Context context, int color) {
    final int one = R.drawable.ic_repeat_one_white_36dp;
    final int all = R.drawable.ic_repeat_white_36dp;
    final LevelListDrawable d = new LevelListDrawable();
    d.addLevel(0, 0, context.getResources().getDrawable(all));
    d.addLevel(1, 1, tintDrawable(context, one, color));
    d.addLevel(2, 2, tintDrawable(context, all, color));
    return d;
}
项目:Orpheus    文件:PlaybackDrawableTint.java   
static void doRepeatDrawable(ImageButton v, boolean is24, int color) {
    int one = is24 ? R.drawable.ic_repeat_one_white_24dp : R.drawable.ic_repeat_one_white_36dp;
    int all = is24 ? R.drawable.ic_repeat_white_24dp : R.drawable.ic_repeat_white_36dp;
    LevelListDrawable d = (LevelListDrawable) v.getDrawable();
    d.addLevel(1, 1, tintDrawable(v.getContext(), one, color));
    d.addLevel(2, 2, tintDrawable(v.getContext(), all, color));
}
项目:NerdzMessenger    文件:ConversationActivity.java   
@Override
public Drawable getDrawable(String source) {
    LevelListDrawable drawable = new LevelListDrawable();
    Drawable empty = ConversationActivity.this.getResources().getDrawable(R.drawable.ic_menu_refresh);
    drawable.addLevel(0, 0, empty);
    drawable.setBounds(0, 0, empty.getIntrinsicWidth(), empty.getIntrinsicHeight());
    new LoadImage().execute(source, drawable, this.mTextView);
    return drawable;
}
项目:NerdzMessenger    文件:ConversationActivity.java   
@Override
protected Bitmap doInBackground(Object... params) {
    String source = (String) params[0];
    this.mDrawable = (LevelListDrawable) params[1];
    this.mTextView = (TextView) params[2];
    Log.d(TAG, "doInBackground source " + source);
    try {
        URL imgUrl = new URL(source);
        HttpURLConnection httpConn = (HttpURLConnection) imgUrl.openConnection();
        InputStream is = new URL(source).openStream();
        return BitmapFactory.decodeStream(is);
    } catch (Exception ignored) {
    }
    return null;
}
项目:apps-android-wikipedia    文件:AudioUrlSpan.java   
@NonNull
private static Drawable drawable(Context context) {
    LevelListDrawable levels = new AppLevelListDrawable();
    levels.addLevel(PLAY_ICON_LEVEL, PLAY_ICON_LEVEL, spinnerDrawable(context));
    levels.addLevel(STOP_ICON_LEVEL, STOP_ICON_LEVEL, speakerDrawable(context));
    int radius = getDimensionPixelSize(context, R.dimen.audio_url_span_loading_spinner_radius);
    levels.setBounds(0, 0, radius * 2, radius * 2);
    return levels;
}
项目:DsaTab    文件:Util.java   
public static void applyRowStyle(Markable markable, View row, int position) {
    if (row.getBackground() instanceof LevelListDrawable) {
           LevelListDrawable levelListDrawable = (LevelListDrawable) row.getBackground();

           int level = position % 2;
           if (markable.isFavorite())
               level += 2;
           else if (markable.isUnused())
               level += 4;

           levelListDrawable.setLevel(level);
       }

}
项目:DsaTab    文件:Util.java   
public static void applyRowStyle(View row, int position) {
    if (row == null)
        return;

       if (row.getBackground() instanceof LevelListDrawable) {
           LevelListDrawable levelListDrawable = (LevelListDrawable) row.getBackground();
           levelListDrawable.setLevel(position % 2);
       }
}
项目:AssistantBySDK    文件:AccountingEditActivity.java   
@Override
public void switchAccountType(int type) {
    LevelListDrawable ld = (LevelListDrawable) mAibType1.getBackground();
    ld.setLevel(type);
}
项目:AssistantBySDK    文件:PlayerHeaderFragment.java   
private void updatePlayBar(boolean playing) {
    LevelListDrawable drawable = (LevelListDrawable) mPlayBt.getDrawable();
    drawable.setLevel(playing ? 0 : 1);
}
项目:AssistantBySDK    文件:TingAlbumDetailAdapter.java   
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (position == 0) {
        HeaderHolder headerHolder = (HeaderHolder) holder;
        //专辑详情
        Glide.with(mContext).load(mAlbum.getCoverUrlMiddle()).into(headerHolder.mIvAlbum);
        headerHolder.mTvAlbumTitle.setText(mAlbum.getAlbumTitle());
        LastUpTrack lastUptrack = mAlbum.getLastUptrack();
        StringBuilder sb = new StringBuilder();
        headerHolder.mTvLastTrack.setText(sb.append("更新至").append(TimeUtils.formatDate(new Date(lastUptrack.getCreatedAt()))).append("  ").append(lastUptrack.getTrackTitle()).toString());
        sb.setLength(0);
        headerHolder.mTvPlayCount.setText(sb.append(StringUtils.formPlayCount(mAlbum.getPlayCount())).append("次播放").toString());
        sb.setLength(0);
        headerHolder.mTvTrackCount.setText(sb.append(mAlbum.getIncludeTrackCount()).append("集").toString());
        //订阅状态
        boolean isSubscribe = mAlbumDao.isSubscribe(mAlbumId);
        headerHolder.mTvSubscribe.setText(isSubscribe ? "已订阅" : "订阅");
        LevelListDrawable ld = (LevelListDrawable) headerHolder.mTvSubscribe.getBackground();
        ld.setLevel(isSubscribe ? 1 : 0);

        if (mHistory != null) {
            headerHolder.mRlHistoryBox.setVisibility(View.VISIBLE);
            sb.setLength(0);
            headerHolder.mTvHistoryTitle.setText(sb.append("继续播放:").append(mHistory.getTrackTitle()).toString());
            sb.setLength(0);
            NumberFormat nf = NumberFormat.getPercentInstance();
            //返回数的整数部分所允许的最大位数
            nf.setMaximumIntegerDigits(3);
            //返回数的小数部分所允许的最大位数
            nf.setMaximumFractionDigits(0);
            headerHolder.mTvProgress.setText(sb.append("已播  ").append(nf.format(mHistory.getBreakPos() / (double) mHistory.getDuration())).toString());
            headerHolder.mIvTingSwitch.setImageLevel((XmlyManager.get().isPlaying() && playTrackId == mHistory.getTrackId()) ? 1 : 0);
        } else {
            headerHolder.mRlHistoryBox.setVisibility(View.GONE);
        }

    } else {
        Track track = mTracks.get(position);
        TrackDetailHolder detailHolder = (TrackDetailHolder) holder;
        detailHolder.mTvTrackTitle.setText(track.getTrackTitle());
        detailHolder.mTvTrackTitle.setTextColor(track.getDataId() == playTrackId
                ? mContext.getResources().getColor(R.color.second_base_color)
                : mContext.getResources().getColor(R.color.new_text_color_first));
        detailHolder.mIvTingSwitch.setImageLevel(0);
        if (track.getDataId() == playTrackId)
            detailHolder.mIvTingSwitch.setImageLevel(XmlyManager.get().isPlaying() ? 1 : 0);
        detailHolder.mTvCreated.setText(TimeUtils.getInstance().getDateString(new Date(track.getCreatedAt())));
        detailHolder.mTvDuration.setText(new SimpleDate().formDuration(track.getDuration()));
    }
}
项目:target-layout    文件:TargetLayout.java   
public void setLevelListDrawable(@NonNull LevelListDrawable levelListDrawable) {
    this.levelListDrawable = levelListDrawable;
}
项目:science-journal    文件:SensorAnimationBehavior.java   
private Drawable getLevelDrawable(Context context) {
    LevelListDrawable drawable =
            (LevelListDrawable) context.getResources().getDrawable(mLevelDrawableId);
    drawable.setLevel(0);
    return drawable;
}
项目:target-layout    文件:TargetLayout.java   
public void setLevelListDrawable(@NonNull LevelListDrawable levelListDrawable) {
    this.levelListDrawable = levelListDrawable;
}
项目:DroneControl    文件:TimeView.java   
public TimeView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a = context.getTheme().obtainStyledAttributes(
            attrs, R.styleable.TimeView, 0, 0);
    try {
        TypedValue textSizeValue = new TypedValue();
        if (a.getValue(R.styleable.TimeView_textSize, textSizeValue)) {
            if (textSizeValue.type == TypedValue.TYPE_DIMENSION) {
                mTextSize = a.getDimensionPixelSize(R.styleable.TimeView_textSize,
                        ViewGroup.LayoutParams.MATCH_PARENT);
                setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
            }
        }

        mTimeType = TimeType.values()[a.getInt(R.styleable.TimeView_timeType, 0)];
        mTemplate = a.getString(R.styleable.TimeView_template);
        mFontPath = a.getString(R.styleable.TimeView_fontPath);

        if (getTimeStateCount() > 1) {
            if (getBackground() instanceof LevelListDrawable) {
                // Do nothing.
            } else {
                final int textArrayId = a.getResourceId(R.styleable.TimeView_textArray, 0);
                if (textArrayId != 0) {
                    mTimeTextResArray = loadTextResArray(
                            getResources().getIntArray(textArrayId));
                } else {
                    mTimeTextResArray = getDefaultTimeTextResArray();
                }
                if (mTimeTextResArray != null && mTimeTextResArray.length > 0) {
                    // This gives the view a default size.
                    setText(mTimeTextResArray[0]);
                }
            }
        }

    } finally {
        a.recycle();
    }

    if (mFontPath != null) {
        try {
            setTypeface(sFontCache.getFont(context, mFontPath));
        } catch (RuntimeException ex) {
            if (isInEditMode()) {
                System.out.println("Custom fonts are not visible in the layout editor.");
            }
        }
    }

    mFontPaint = new TextPaint(getPaint());
}