当前位置: 首页>>代码示例>>Java>>正文


Java LevelListDrawable类代码示例

本文整理汇总了Java中android.graphics.drawable.LevelListDrawable的典型用法代码示例。如果您正苦于以下问题:Java LevelListDrawable类的具体用法?Java LevelListDrawable怎么用?Java LevelListDrawable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LevelListDrawable类属于android.graphics.drawable包,在下文中一共展示了LevelListDrawable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onFinishInflate

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
@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);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:RecentTabsGroupView.java

示例2: init

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
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);
    }
 
开发者ID:tsalik,项目名称:target-layout,代码行数:21,代码来源:TargetLayout.java

示例3: updateColor

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
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);
    }
}
 
开发者ID:Maxr1998,项目名称:home-assistant-Android,代码行数:22,代码来源:SwitchViewHolder.java

示例4: loadFromMemCache

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
@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;
}
 
开发者ID:ROKOLabs,项目名称:ROKO.Stickers-Android,代码行数:17,代码来源:LevelListImageFetchTask.java

示例5: onFinishInflate

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
@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);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:19,代码来源:RecentTabsGroupView.java

示例6: onCreate

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
@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);
}
 
开发者ID:KamiSempai,项目名称:NinePatchBuildUtils,代码行数:22,代码来源:LevelListExampleActivity.java

示例7: assertEquals

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
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]);

}
 
开发者ID:jmarranz,项目名称:itsnat_droid,代码行数:25,代码来源:Assert.java

示例8: getDrawable

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
@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;
}
 
开发者ID:Mindjet,项目名称:LiteReader,代码行数:34,代码来源:RichTextView.java

示例9: init

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
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();
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:8,代码来源:RspMsgItemView.java

示例10: onBindViewHolder

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
@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);
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:14,代码来源:ChooseSetPopupWindow.java

示例11: init

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
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();
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:34,代码来源:RealTimeUpdateSearchBox.java

示例12: onClick

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:37,代码来源:ChatListAdapter.java

示例13: instantiateItem

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
@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);
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:28,代码来源:TrafficShowPresenter.java

示例14: setDot

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
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);
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:9,代码来源:GuideActivity.java

示例15: loadFromDiskCache

import android.graphics.drawable.LevelListDrawable; //导入依赖的package包/类
@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;
}
 
开发者ID:ROKOLabs,项目名称:ROKO.Stickers-Android,代码行数:16,代码来源:LevelListImageFetchTask.java


注:本文中的android.graphics.drawable.LevelListDrawable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。