當前位置: 首頁>>代碼示例>>Java>>正文


Java TextDrawable類代碼示例

本文整理匯總了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));
}
 
開發者ID:AbyxBelgium,項目名稱:Loyalty,代碼行數:18,代碼來源:CardAdapter.java

示例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;
}
 
開發者ID:michaelprimez,項目名稱:searchablespinner,代碼行數:25,代碼來源:SimpleListAdapter.java

示例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);
}
 
開發者ID:PalisadoesFoundation,項目名稱:do-road,代碼行數:27,代碼來源:RequestListAdapter.java

示例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);
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:13,代碼來源:GeneratedContactPhoto.java

示例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;
            }
        });
    }

}
 
開發者ID:Onelio,項目名稱:ConnectU,代碼行數:20,代碼來源:NotificationsMiniAdapter.java

示例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));
}
 
開發者ID:SamuelGjk,項目名稱:GComic,代碼行數:17,代碼來源:ResultListAdapter.java

示例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)));
}
 
開發者ID:SamuelGjk,項目名稱:GComic,代碼行數:17,代碼來源:ClassifyListAdapter.java

示例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;
}
 
開發者ID:genonbeta,項目名稱:TrebleShot,代碼行數:24,代碼來源:NetworkDeviceListAdapter.java

示例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);
	}
}
 
開發者ID:genonbeta,項目名稱:TrebleShot,代碼行數:25,代碼來源:HomeActivity.java

示例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);
}
 
開發者ID:UWICompSociety,項目名稱:OurVLE,代碼行數:24,代碼來源:MemberListAdapter.java

示例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);
}
 
開發者ID:UWICompSociety,項目名稱:OurVLE,代碼行數:26,代碼來源:ForumListAdapter.java

示例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);
}
 
開發者ID:zhenhaoli,項目名稱:Unificiency,代碼行數:21,代碼來源:GroupsAdapter.java

示例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;

}
 
開發者ID:zhenhaoli,項目名稱:Unificiency,代碼行數:23,代碼來源:GroupMemberAdapter.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-wave-android,代碼行數:24,代碼來源:DrawableProvider.java

示例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;
  }
}
 
開發者ID:Agilitum,項目名稱:TextSecureSMP,代碼行數:24,代碼來源:ContactPhotoFactory.java


注:本文中的com.amulyakhare.textdrawable.TextDrawable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。