本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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]);
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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;
}