com.amulyakhare.textdrawable.TextDrawable Java Examples
The following examples show how to use
com.amulyakhare.textdrawable.TextDrawable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainViewModel.java From hacker-news-android with Apache License 2.0 | 6 votes |
IProfile[] getLoggedInProfileItem() { if (mLoggedInProfiles == null) { mLoggedInProfiles = new IProfile[2]; User currentUser = Select.from(User.class).first(); ProfileDrawerItem profileDrawerItem = new ProfileDrawerItem().withIdentifier(LOGGED_IN_PROFILE_ITEM) .withIcon(TextDrawable.builder() .buildRound(String.valueOf(currentUser.getUserName().charAt(0)), mResources.getColor(R.color.colorPrimaryDark))) .withName(currentUser.getUserName()); ProfileSettingDrawerItem logoutDrawerItem = new ProfileSettingDrawerItem().withIdentifier(LOG_OUT_PROFILE_ITEM) .withName("Logout") .withDescription("Logout of current account") .withIcon(mResources.getDrawable(R.drawable.ic_close)); mLoggedInProfiles[0] = profileDrawerItem; mLoggedInProfiles[1] = logoutDrawerItem; } return mLoggedInProfiles; }
Example #2
Source File: StarkSpinnerAdapter.java From SSForms with GNU General Public License v3.0 | 6 votes |
private TextDrawable getTextDrawable(String displayName) { TextDrawable drawable; 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; }
Example #3
Source File: ReviewsViewHolder.java From PopularMovies with MIT License | 6 votes |
public void bindTo(final Review review) { String userName = review.getAuthor(); // review user image ColorGenerator generator = ColorGenerator.MATERIAL; int color = generator.getRandomColor(); TextDrawable drawable = TextDrawable.builder() .buildRound(userName.substring(0, 1).toUpperCase(), color); binding.imageAuthor.setImageDrawable(drawable); // review's author binding.textAuthor.setText(userName); // review's content binding.textContent.setText(review.getContent()); binding.executePendingBindings(); }
Example #4
Source File: SimpleListAdapter.java From searchablespinner with Apache License 2.0 | 6 votes |
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; }
Example #5
Source File: SimpleArrayListAdapter.java From searchablespinner with Apache License 2.0 | 6 votes |
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; }
Example #6
Source File: TabManager.java From SimplicityBrowser with MIT License | 6 votes |
public static void updateTabView(){ VIEW.getMenu().clear(); for(int i = 0;i < mViewsList.size();i++) { NestedWebview view = mViewsList.get(i); VIEW.getMenu().add(view.getTitle()); if(view == TabManager.currentTab){ VIEW.getMenu().getItem(i).setChecked(true); } else{ VIEW.getMenu().getItem(i).setChecked(false); } } for(int i = 0;i < VIEW.getMenu().size() ; i++){ int col = ContextCompat.getColor(SimplicityApplication.getContextOfApplication(), R.color.md_blue_600); TextDrawable drawable = TextDrawable.builder().buildRound("",col); VIEW.getMenu().getItem(i).setIcon(drawable); } }
Example #7
Source File: WeekdaysDrawableProvider.java From weekdays-buttons-bar with MIT License | 6 votes |
public Drawable getRectWithCustomSize(Context context, String leftText, String rightText, boolean selected) { TextDrawable.IBuilder builder = TextDrawable.builder() .beginConfig() .width(toPx(context, 29)) .withBorder(toPx(context, 2)) .textColor(selected ? getTextColorSelected() : getTextColorUnselected()) .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(context, 31), 0), new InsetDrawable(right, toPx(context, 31), 0, 0, 0) }; return new LayerDrawable(layerList); }
Example #8
Source File: DrawableProvider.java From TextDrawable with MIT License | 6 votes |
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); }
Example #9
Source File: GeneratedContactPhoto.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public Drawable asDrawable(Context context, int color, boolean inverted) { int targetSize = context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size); String character = getAbbreviation(name); if (!TextUtils.isEmpty(character)) { Drawable base = TextDrawable.builder() .beginConfig() .width(targetSize) .height(targetSize) .useFont(TYPEFACE) .fontSize(ViewUtil.dpToPx(context, 24)) .textColor(inverted ? color : Color.WHITE) .endConfig() .buildRound(character, inverted ? Color.WHITE : color); Drawable gradient = context.getResources().getDrawable(ThemeUtil.isDarkTheme(context) ? R.drawable.avatar_gradient_dark : R.drawable.avatar_gradient_light); return new LayerDrawable(new Drawable[] { base, gradient }); } return new ResourceContactPhoto(fallbackResId).asDrawable(context, color, inverted); }
Example #10
Source File: HeadItemTwoNoFragmentLoadOnChangeActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 6 votes |
private MaterialHeadItem getHeadItem2() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1", new FragmentDummy(), "Section 1")); menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2")); menu.add(new MaterialItemSectionFragment(this, "Section 3", new FragmentDummy(), "Section 3")); // create Head Item TextDrawable headPhoto = TextDrawable.builder() .buildRound("B", Color.BLUE); MaterialHeadItem headItem = new MaterialHeadItem(this, "B HeadItem", "B Subtitle", headPhoto, R.drawable.mat6, menu); // don't change fragment on change headItem.setLoadFragmentOnChanged(false); return headItem; }
Example #11
Source File: HeadItemFiveDontCloseOnChangeActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 6 votes |
private MaterialHeadItem getHeadItem2() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 2)", new FragmentDummy(), "Section 1 (Head 2)")); menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2")); // create Head Item TextDrawable headPhoto = TextDrawable.builder() .buildRound("B", Color.BLUE); MaterialHeadItem headItem = new MaterialHeadItem(this, "B HeadItem", "B Subtitle", headPhoto, R.drawable.mat6, menu); headItem.setCloseDrawerOnChanged(false); // don't close the drawer, if this head item chosen return headItem; }
Example #12
Source File: HeadItemThreeDontCloseOnChangeActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 6 votes |
private MaterialHeadItem getHeadItem2() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 2)", new FragmentDummy(), "Section 1 (Head 2)")); menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2")); // create Head Item TextDrawable headPhoto = TextDrawable.builder() .buildRound("B", Color.BLUE); MaterialHeadItem headItem = new MaterialHeadItem(this, "B HeadItem", "B Subtitle", headPhoto, R.drawable.mat6, menu); headItem.setCloseDrawerOnChanged(false); // don't close the drawer, if this head item chosen return headItem; }
Example #13
Source File: WeekdaysDrawableProvider.java From weekdays-buttons-bar with MIT License | 6 votes |
public static Drawable getRectWithAnimation(int count, String label, int delay) { TextDrawable.IBuilder builder = TextDrawable.builder() .rect(); AnimationDrawable animationDrawable = new AnimationDrawable(); for (int i = count; i > 0; i--) { TextDrawable frame = builder.build(label, ColorGenerator.MATERIAL.getRandomColor()); animationDrawable.addFrame(frame, delay); } animationDrawable.setOneShot(false); animationDrawable.start(); return animationDrawable; }
Example #14
Source File: AddRemoveHeadItemRuntimeActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 6 votes |
private MaterialHeadItem getHeadItem3() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head " + headCount + ")", this.getResources().getDrawable(R.drawable.ic_favorite_black_36dp), new FragmentDummy(), "Section 1 (Head " + headCount + ")")); menu.add(new MaterialItemSectionFragment(this, "Section 2 (Head " + headCount + ")", new FragmentDummy(), "Section 2 (Head " + headCount + ")")); // create headItem TextDrawable headPhoto = TextDrawable.builder() .buildRound(headCount+"", Color.BLUE); MaterialHeadItem headItem = new MaterialHeadItem(this, headCount+" HeadItem No Menu", headCount+" Subtitle", headPhoto, R.drawable.mat6, menu); // counter for the new headItem headCount++; return headItem; }
Example #15
Source File: HeadItemTwoExtraMenuActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 5 votes |
private MaterialHeadItem getHeadItem2() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 2)", new FragmentDummy(), "Section 1 (Head 2)")); menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2")); // create Head Item TextDrawable headPhoto = TextDrawable.builder() .buildRound("B", Color.BLUE); MaterialHeadItem headItem = new MaterialHeadItem(this, "B HeadItem", "B Subtitle", headPhoto, R.drawable.mat6, menu); return headItem; }
Example #16
Source File: HeadItemThreeActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 5 votes |
private MaterialHeadItem getHeadItem3() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 3)", new FragmentDummy(), "Section 1 (Head 3)")); menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2")); // create Head Item TextDrawable headPhoto = TextDrawable.builder() .buildRound("C", Color.GRAY); MaterialHeadItem headItem = new MaterialHeadItem(this, "C HeadItem", "C Subtitle", headPhoto, R.drawable.mat6, menu); return headItem; }
Example #17
Source File: HeadItemFiveActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 5 votes |
private MaterialHeadItem getHeadItem4() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 4)", new FragmentDummy(), "Section 1 (Head 4)")); menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2")); // create Head Item TextDrawable headPhoto = TextDrawable.builder() .buildRound("D", Color.GRAY); MaterialHeadItem headItem = new MaterialHeadItem(this, "D HeadItem", "D Subtitle", headPhoto, R.drawable.mat6, menu); return headItem; }
Example #18
Source File: HeadItemFiveActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 5 votes |
private MaterialHeadItem getHeadItem3() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 3)", new FragmentDummy(), "Section 1 (Head 3)")); menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2")); // create Head Item TextDrawable headPhoto = TextDrawable.builder() .buildRound("C", Color.GRAY); MaterialHeadItem headItem = new MaterialHeadItem(this, "C HeadItem", "C Subtitle", headPhoto, R.drawable.mat6, menu); return headItem; }
Example #19
Source File: HeadItemFiveActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 5 votes |
private MaterialHeadItem getHeadItem2() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 2)", new FragmentDummy(), "Section 1 (Head 2)")); menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2")); // create Head Item TextDrawable headPhoto = TextDrawable.builder() .buildRound("B", Color.BLUE); MaterialHeadItem headItem = new MaterialHeadItem(this, "B HeadItem", "B Subtitle", headPhoto, R.drawable.mat6, menu); return headItem; }
Example #20
Source File: HeadItemThreeDontCloseOnChangeActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 5 votes |
private MaterialHeadItem getHeadItem3() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 3)", new FragmentDummy(), "Section 1 (Head 3)")); menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2")); // create Head Item TextDrawable headPhoto = TextDrawable.builder() .buildRound("C", Color.GRAY); MaterialHeadItem headItem = new MaterialHeadItem(this, "C HeadItem", "C Subtitle", headPhoto, R.drawable.mat6, menu); headItem.setCloseDrawerOnChanged(false); // don't close the drawer, if this head item chosen return headItem; }
Example #21
Source File: WeekdaysPicker.java From Weekdays-Selector with MIT License | 5 votes |
private void initDrawableBuilders() { // declare the builder object once. selectedIShapeBuilder = TextDrawable.builder(); selectedIShapeBuilder.beginConfig() .textColor(selectedTextColor) .fontSize(getDpFromPx(fontSize)) .bold() .width(fullSize ? getScreenWidth() / 5 : getDpFromPx(width)) .height(getDpFromPx(height)) .endConfig(); unselectedIShapeBuilder = TextDrawable.builder(); unselectedIShapeBuilder.beginConfig() .textColor(unSelectedTextColor) .fontSize(getDpFromPx(fontSize)) .bold() .width(fullSize ? getScreenWidth() / 5 : getDpFromPx(width)) .height(getDpFromPx(height)) .endConfig(); unselectedWeekendIShapeBuilder = TextDrawable.builder(); unselectedWeekendIShapeBuilder.beginConfig() .textColor(weekendDarker ? unSelectedWeekendTextColor : unSelectedTextColor) .fontSize(getDpFromPx(fontSize)) .bold() .width(fullSize ? getScreenWidth() / 5 : getDpFromPx(width)) .height(getDpFromPx(height)) .endConfig(); }
Example #22
Source File: DrawableProvider.java From TextDrawable with MIT License | 5 votes |
public TextDrawable getRoundRectWithBorder(String text) { return TextDrawable.builder() .beginConfig() .withBorder(toPx(2)) .endConfig() .buildRoundRect(text, mGenerator.getColor(text), toPx(10)); }
Example #23
Source File: HeadItemThreeChangeListenerActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 5 votes |
private MaterialHeadItem getHeadItem3() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 3)", new FragmentDummy(), "Section 1 (Head 3)")); menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2")); // create Head Item TextDrawable headPhoto = TextDrawable.builder() .buildRound("C", Color.GRAY); MaterialHeadItem headItem = new MaterialHeadItem(this, "C HeadItem", "C Subtitle", headPhoto, R.drawable.mat6, menu); return headItem; }
Example #24
Source File: HeadItemThreeChangeListenerActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 5 votes |
private MaterialHeadItem getHeadItem2() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 2)", new FragmentDummy(), "Section 1 (Head 2)")); menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2")); // create Head Item TextDrawable headPhoto = TextDrawable.builder() .buildRound("B", Color.BLUE); MaterialHeadItem headItem = new MaterialHeadItem(this, "B HeadItem", "B Subtitle", headPhoto, R.drawable.mat6, menu); return headItem; }
Example #25
Source File: HeadItemFiveDontCloseOnChangeActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 5 votes |
private MaterialHeadItem getHeadItem3() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 3)", new FragmentDummy(), "Section 1 (Head 3)")); menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2")); // create Head Item TextDrawable headPhoto = TextDrawable.builder() .buildRound("C", Color.GRAY); MaterialHeadItem headItem = new MaterialHeadItem(this, "C HeadItem", "C Subtitle", headPhoto, R.drawable.mat6, menu); headItem.setCloseDrawerOnChanged(false); // don't close the drawer, if this head item chosen return headItem; }
Example #26
Source File: AddRemoveHeadItemRuntimeActivity.java From AdvancedMaterialDrawer with Apache License 2.0 | 5 votes |
private MaterialHeadItem getHeadItem2() { // create menu MaterialMenu menu = new MaterialMenu(); menu.add(new MaterialItemSectionFragment(this, "Section 1", this.getResources().getDrawable(R.drawable.ic_favorite_black_36dp), new FragmentDummy(), "Section 1")); menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2")); // create headItem TextDrawable headPhoto = TextDrawable.builder() .buildRound("B", Color.BLUE); MaterialHeadItem headItem = new MaterialHeadItem(this, "B HeadItem No Menu", "B Subtitle", headPhoto, R.drawable.mat6, menu); return headItem; }
Example #27
Source File: DrawableProvider.java From TextDrawable with MIT License | 5 votes |
public Drawable getRectWithAnimation() { TextDrawable.IBuilder builder = TextDrawable.builder() .rect(); AnimationDrawable animationDrawable = new AnimationDrawable(); for (int i = 10; i > 0; i--) { TextDrawable frame = builder.build(String.valueOf(i), mGenerator.getRandomColor()); animationDrawable.addFrame(frame, 1200); } animationDrawable.setOneShot(false); animationDrawable.start(); return animationDrawable; }
Example #28
Source File: DrawableProvider.java From TextDrawable with MIT License | 5 votes |
public TextDrawable getRoundWithBorder(String text) { return TextDrawable.builder() .beginConfig() .withBorder(toPx(2)) .endConfig() .buildRound(text, mGenerator.getColor(text)); }
Example #29
Source File: DrawableProvider.java From TextDrawable with MIT License | 5 votes |
public TextDrawable getRoundWithCustomFont() { String text = "Bold"; return TextDrawable.builder() .beginConfig() .useFont(Typeface.DEFAULT) .fontSize(toPx(15)) .textColor(0xfff58559) .bold() .endConfig() .buildRect(text, Color.DKGRAY /*toPx(5)*/); }
Example #30
Source File: DrawableProvider.java From TextDrawable with MIT License | 5 votes |
public TextDrawable getRectWithMultiLetter() { String text = "AK"; return TextDrawable.builder() .beginConfig() .fontSize(toPx(20)) .toUpperCase() .endConfig() .buildRect(text, mGenerator.getColor(text)); }