java类android.graphics.drawable.LevelListDrawable的实例源码

RecentTabsGroupView.java 文件源码 项目:chromium-for-android-56-debug-video 阅读 24 收藏 0 点赞 0 评论 0
@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);
}
TargetLayout.java 文件源码 项目:target-layout 阅读 31 收藏 0 点赞 0 评论 0
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);
    }
SwitchViewHolder.java 文件源码 项目:home-assistant-Android 阅读 23 收藏 0 点赞 0 评论 0
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);
    }
}
LevelListImageFetchTask.java 文件源码 项目:ROKO.Stickers-Android 阅读 24 收藏 0 点赞 0 评论 0
@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;
}
TargetLayout.java 文件源码 项目:target-layout 阅读 22 收藏 0 点赞 0 评论 0
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);
    }
RecentTabsGroupView.java 文件源码 项目:AndroidChromium 阅读 24 收藏 0 点赞 0 评论 0
@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);
}
RecentTabsGroupView.java 文件源码 项目:Vafrinn 阅读 17 收藏 0 点赞 0 评论 0
@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);
}
RecentTabsGroupView.java 文件源码 项目:365browser 阅读 19 收藏 0 点赞 0 评论 0
@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);
}
LevelListExampleActivity.java 文件源码 项目:NinePatchBuildUtils 阅读 25 收藏 0 点赞 0 评论 0
@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);
}
Assert.java 文件源码 项目:itsnat_droid 阅读 33 收藏 0 点赞 0 评论 0
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]);

}
RichTextView.java 文件源码 项目:LiteReader 阅读 36 收藏 0 点赞 0 评论 0
@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;
}
RspMsgItemView.java 文件源码 项目:AssistantBySDK 阅读 20 收藏 0 点赞 0 评论 0
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();
}
ChooseSetPopupWindow.java 文件源码 项目:AssistantBySDK 阅读 17 收藏 0 点赞 0 评论 0
@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);
}
RealTimeUpdateSearchBox.java 文件源码 项目:AssistantBySDK 阅读 27 收藏 0 点赞 0 评论 0
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();
}
ChatListAdapter.java 文件源码 项目:AssistantBySDK 阅读 31 收藏 0 点赞 0 评论 0
@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;
    }
}
TrafficShowPresenter.java 文件源码 项目:AssistantBySDK 阅读 27 收藏 0 点赞 0 评论 0
@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);
}
GuideActivity.java 文件源码 项目:AssistantBySDK 阅读 29 收藏 0 点赞 0 评论 0
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);
    }
}
LevelListImageFetchTask.java 文件源码 项目:ROKO.Stickers-Android 阅读 18 收藏 0 点赞 0 评论 0
@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;
}
AudioUrlSpan.java 文件源码 项目:xowa_android 阅读 21 收藏 0 点赞 0 评论 0
@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;
}
URLImageParser.java 文件源码 项目:H-Viewer 阅读 20 收藏 0 点赞 0 评论 0
@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;
}
SNoticeDetail.java 文件源码 项目:SIHSchool 阅读 24 收藏 0 点赞 0 评论 0
@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;
}
ClassDescLevelListDrawable.java 文件源码 项目:itsnat_droid 阅读 19 收藏 0 点赞 0 评论 0
@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;
}
PlaybackDrawableTint.java 文件源码 项目:Orpheus 阅读 24 收藏 0 点赞 0 评论 0
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;
}
PlaybackDrawableTint.java 文件源码 项目:Orpheus 阅读 22 收藏 0 点赞 0 评论 0
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;
}
PlaybackDrawableTint.java 文件源码 项目:Orpheus 阅读 20 收藏 0 点赞 0 评论 0
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));
}
PlaybackDrawableTint.java 文件源码 项目:Orpheus 阅读 27 收藏 0 点赞 0 评论 0
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;
}
PlaybackDrawableTint.java 文件源码 项目:Orpheus 阅读 28 收藏 0 点赞 0 评论 0
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;
}
PlaybackDrawableTint.java 文件源码 项目:Orpheus 阅读 21 收藏 0 点赞 0 评论 0
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));
}
ConversationActivity.java 文件源码 项目:NerdzMessenger 阅读 27 收藏 0 点赞 0 评论 0
@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;
}
ConversationActivity.java 文件源码 项目:NerdzMessenger 阅读 26 收藏 0 点赞 0 评论 0
@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;
}


问题


面经


文章

微信
公众号

扫码关注公众号