本文整理汇总了Java中com.amulyakhare.textdrawable.TextDrawable类的典型用法代码示例。如果您正苦于以下问题:Java TextDrawable类的具体用法?Java TextDrawable怎么用?Java TextDrawable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextDrawable类属于com.amulyakhare.textdrawable包,在下文中一共展示了TextDrawable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CardViewHolder
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
public CardViewHolder(View itemView) {
super(itemView, clickListener);
textView = itemView.findViewById(R.id.textView);
imageView = itemView.findViewById(R.id.imageView);
imageView2 = itemView.findViewById(R.id.imageView2);
rootLayout = itemView.findViewById(R.id.rootLayout);
viewFlipper = itemView.findViewById(R.id.viewFlipper);
DrawableManager drawableManager = new DrawableManager();
whiteBackground = drawableManager.getDrawable(context, null, R.color.white);
blackBackground = drawableManager.getDrawable(context, null, R.color.bg_home);
imageView2.setImageDrawable(TextDrawable.builder().buildRound("✓", Color.GRAY));
viewFlipper.setInAnimation(AnimationUtils.loadAnimation(context, R.anim.flip_left_in));
viewFlipper.setOutAnimation(AnimationUtils.loadAnimation(context, R.anim.flip_left_out));
}
示例2: getTextDrawable
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
private TextDrawable getTextDrawable(String displayName) {
TextDrawable drawable = null;
if (!TextUtils.isEmpty(displayName)) {
int color2 = ColorGenerator.MATERIAL.getColor(displayName);
drawable = TextDrawable.builder()
.beginConfig()
.width(UITools.dpToPx(mContext, 32))
.height(UITools.dpToPx(mContext, 32))
.textColor(Color.WHITE)
.toUpperCase()
.endConfig()
.round()
.build(displayName.substring(0, 1), color2);
} else {
drawable = TextDrawable.builder()
.beginConfig()
.width(UITools.dpToPx(mContext, 32))
.height(UITools.dpToPx(mContext, 32))
.endConfig()
.round()
.build("?", Color.GRAY);
}
return drawable;
}
示例3: onBindViewHolder
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
@Override
public void onBindViewHolder(RequestViewHolder holder, int position) {
Request request = mRequests.get(position);
String name = request.getName();
holder.tvName.setText(request.getName());
holder.tvTime.setText(request.getDatetime());
char firstLetter = name.toUpperCase().charAt(0);
ColorGenerator generator = ColorGenerator.MATERIAL;
int color2 = generator.getColor(name);
TextDrawable drawable2 =
TextDrawable.builder()
.beginConfig()
.textColor(Color.WHITE)
.useFont(Typeface.DEFAULT)
.toUpperCase()
.endConfig()
.buildRound(firstLetter + "", color2);
holder.imgIcon.setImageDrawable(drawable2);
}
示例4: asDrawable
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
@Override
public Drawable asDrawable(Context context, int color, boolean inverted) {
int targetSize = context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size);
return TextDrawable.builder()
.beginConfig()
.width(targetSize)
.height(targetSize)
.textColor(inverted ? color : Color.WHITE)
.endConfig()
.buildRound(getCharacter(name), inverted ? Color.WHITE : color);
}
示例5: onBindViewHolder
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, final int position) {
String name = NotificationsParser.getName(values.get(position));
if (!name.isEmpty()) {
holder.objName.setText(name);
Drawable drawable = TextDrawable.builder().buildRound(String.valueOf(name.charAt(0)), Color.parseColor(ColorHelper.getColor(name.charAt(0))));
holder.objImage.setImageDrawable(drawable);
holder.llayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
listener.onItemClick(position, values.get(position), v);
}
return true;
}
});
}
}
示例6: onBindViewHolder
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.result = mData.get(position);
// @formatter:off
TextDrawable placeholder = TextDrawable.builder().buildRect(Utils.getFirstCharacter(holder.result.title), mColorGenerator.getColor(holder.result.title));
Glide.with(mContext)
.load(GlideUrlFactory.newGlideUrlInstance(holder.result.cover))
.placeholder(placeholder)
.into(holder.comicCover);
holder.comicTitle.setText(holder.result.title);
holder.comicTitle.setText(holder.result.title);
holder.comicAuthors.setText(mContext.getString(R.string.comic_author_placeholder, holder.result.authors));
holder.comicTypes.setText(mContext.getString(R.string.comic_type_placeholder, holder.result.types));
holder.lastUpdateTime.setText(mContext.getString(R.string.comic_last_name_placeholder, holder.result.lastName));
}
示例7: onBindViewHolder
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.classify = mData.get(position);
// @formatter:off
TextDrawable placeholder = TextDrawable.builder().buildRect(Utils.getFirstCharacter(holder.classify.title), mColorGenerator.getColor(holder.classify.title));
Glide.with(mContext)
.load(GlideUrlFactory.newGlideUrlInstance(holder.classify.cover))
.placeholder(placeholder)
.into(holder.comicCover);
holder.comicTitle.setText(holder.classify.title);
holder.comicTitle.setText(holder.classify.title);
holder.comicAuthors.setText(mContext.getString(R.string.comic_author_placeholder, holder.classify.authors));
holder.comicTypes.setText(mContext.getString(R.string.comic_type_placeholder, holder.classify.types));
holder.lastUpdateTime.setText(mContext.getString(R.string.comic_last_update_time_placeholder, DateFormat.format("yyyy-MM-dd", holder.classify.lastUpdatetime * 1000)));
}
示例8: getView
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
@Override
public View getView(int position, View view, ViewGroup viewGroup)
{
if (view == null)
view = getInflater().inflate(R.layout.list_network_device, viewGroup, false);
NetworkDevice device = (NetworkDevice) getItem(position);
String firstLetters = TextUtils.getFirstLetters(device.nickname, 1);
boolean hotspotNetwork = device instanceof HotspotNetwork;
TextView deviceText = view.findViewById(R.id.network_device_list_device_text);
TextView userText = view.findViewById(R.id.network_device_list_user_text);
ImageView userImage = view.findViewById(R.id.network_device_list_device_image);
userText.setText(device.nickname);
deviceText.setText(hotspotNetwork ? mContext.getString(R.string.text_trebleshotHotspot) : device.model);
userImage.setImageDrawable(TextDrawable.builder().buildRoundRect(firstLetters.length() > 0
? firstLetters
: "?", ContextCompat.getColor(mContext, hotspotNetwork ? R.color.hotspotNetworkRipple : R.color.networkDeviceRipple), 100));
return view;
}
示例9: onStart
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
@Override
protected void onStart()
{
super.onStart();
mIsStopped = false;
View headerView = mNavigationView.getHeaderView(0);
if (headerView != null) {
NetworkDevice localDevice = AppUtils.getLocalDevice(getApplicationContext());
ImageView imageView = headerView.findViewById(R.id.header_main_image);
TextView deviceNameText = headerView.findViewById(R.id.header_main_text1);
TextView versionText = headerView.findViewById(R.id.header_main_text2);
String firstLetters = TextUtils.getFirstLetters(localDevice.nickname, 1);
TextDrawable drawable = TextDrawable.builder().buildRoundRect(firstLetters.length() > 0 ? firstLetters : "?", ContextCompat.getColor(getApplicationContext(), R.color.networkDeviceRipple), 100);
imageView.setImageDrawable(drawable);
deviceNameText.setText(localDevice.nickname);
versionText.setText(localDevice.versionName);
}
}
示例10: onBindViewHolder
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
@Override
public void onBindViewHolder(MemberViewHolder holder, int position) {
String name = mMembers.get(position).getFullname();
if(!TextUtils.isEmpty(name)) {
holder.name.setText(mMembers.get(position).getFullname());
}
ColorGenerator generator = ColorGenerator.MATERIAL;
int color2 = generator.getColor(name);
char firstLetter = name.toUpperCase().charAt(0);
TextDrawable drawable2 = TextDrawable.builder()
.beginConfig()
.textColor(Color.WHITE)
.useFont(Typeface.DEFAULT)
.toUpperCase()
.endConfig()
.buildRound(firstLetter + "", color2);
holder.memberpic.setImageDrawable(drawable2);
}
示例11: onBindViewHolder
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
@Override
public void onBindViewHolder(ForumViewHolder holder, int position) {
final Forum forum = mForums.get(position);
if (forum.getName() != null) holder.tvName.setText(forum.getName());
if (forum.getIntro() != null) {
holder.tvDesc.setText(Html.fromHtml(forum.getIntro()).toString().trim()); // converts html to normal string
}
String forumname = forum.getName();
char firstLetter = forumname.toUpperCase().charAt(0);
ColorGenerator generator = ColorGenerator.MATERIAL;
int color2 = generator.getColor(forumname);
TextDrawable drawable2 = TextDrawable.builder()
.beginConfig()
.textColor(Color.WHITE)
.useFont(Typeface.DEFAULT)
.toUpperCase()
.endConfig()
.buildRound(firstLetter + "", color2);
holder.forum_img.setImageDrawable(drawable2);
}
示例12: onBindViewHolder
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
@Override
public void onBindViewHolder(ViewHolderGroups holder, int position) {
Group group = this.data.get(position);
String name = group.getName();
String topic = group.getTopic();
holder.groupNameTextView.setText(name);
if(group.isHasPassword()){
holder.lock.setVisibility(View.VISIBLE);
} else {
holder.lock.setVisibility(View.INVISIBLE);
}
holder.groupTopicTextView.setText("#" + topic);
//make colored circle with text
ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(name);
TextDrawable drawable = TextDrawable.builder()
.buildRoundRect(name.substring(0,2), color, 100);
holder.groupFirtCharsImageView.setImageDrawable(drawable);
holder.bind(group, listener);
}
示例13: getView
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
String member = getItem(position);
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.group_details_member,parent, false);
}
TextView memberViewItem = (TextView) convertView.findViewById(R.id.group_details_member_item);
ImageView leftImg = (ImageView) convertView.findViewById(R.id.group_name_first_chars);
ColorGenerator generator = ColorGenerator.MATERIAL;
TextDrawable circle = TextDrawable.builder()
.buildRound(member.substring(0,1), generator.getColor(member));
leftImg.setImageDrawable(circle);
memberViewItem.setText(member);
return convertView;
}
示例14: getRectWithCustomSize
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
public Drawable getRectWithCustomSize() {
String leftText = "I";
String rightText = "J";
TextDrawable.IBuilder builder = TextDrawable.builder()
.beginConfig()
.width(toPx(29))
.withBorder(toPx(2))
.endConfig()
.rect();
TextDrawable left = builder
.build(leftText, mGenerator.getColor(leftText));
TextDrawable right = builder
.build(rightText, mGenerator.getColor(rightText));
Drawable[] layerList = {
new InsetDrawable(left, 0, 0, toPx(31), 0),
new InsetDrawable(right, toPx(31), 0, 0, 0)
};
return new LayerDrawable(layerList);
}
示例15: getDefaultContactPhoto
import com.amulyakhare.textdrawable.TextDrawable; //导入依赖的package包/类
public static Drawable getDefaultContactPhoto(Context context, @Nullable String name) {
int targetSize = context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size);
if (name != null && !name.isEmpty()) {
return TextDrawable.builder().beginConfig()
.width(targetSize)
.height(targetSize)
.endConfig()
.buildRound(String.valueOf(name.charAt(0)),
COLOR_GENERATOR.getColor(name));
}
synchronized (defaultPhotoLock) {
if (defaultContactPhoto == null)
defaultContactPhoto = TextDrawable.builder().beginConfig()
.width(targetSize)
.height(targetSize)
.endConfig()
.buildRound("#", UNKNOWN_COLOR);
return defaultContactPhoto;
}
}