/**
* Sets the fonts used in the dialog, by file names. This also uses TypefaceHelper in order to
* avoid any un-needed allocations (it recycles typefaces for you).
*
* @param medium The name of font in assets/fonts used on titles and action buttons (null uses
* device default). E.g. [your-project]/app/main/assets/fonts/[medium]
* @param regular The name of font in assets/fonts used everywhere else, like content and list
* items (null uses device default). E.g. [your-project]/app/main/assets/fonts/[regular]
* @return The Builder instance so you can chain calls to it.
*/
public Builder typeface(@Nullable String medium, @Nullable String regular) {
if (medium != null && !medium.trim().isEmpty()) {
this.mediumFont = TypefaceHelper.get(this.context, medium);
if (this.mediumFont == null) {
throw new IllegalArgumentException("No font asset found for \"" + medium + "\"");
}
}
if (regular != null && !regular.trim().isEmpty()) {
this.regularFont = TypefaceHelper.get(this.context, regular);
if (this.regularFont == null) {
throw new IllegalArgumentException("No font asset found for \"" + regular + "\"");
}
}
return this;
}
java类com.afollestad.materialdialogs.util.TypefaceHelper的实例源码
MaterialDialog.java 文件源码
项目:material-dialogs
阅读 33
收藏 0
点赞 0
评论 0
MaterialDialog.java 文件源码
项目:GitHub
阅读 30
收藏 0
点赞 0
评论 0
/**
* Sets the fonts used in the dialog, by file names. This also uses TypefaceHelper in order
* to avoid any un-needed allocations (it recycles typefaces for you).
*
* @param medium The name of font in assets/fonts used on titles and action buttons (null
* uses device default). E.g. [your-project]/app/main/assets/fonts/[medium]
* @param regular The name of font in assets/fonts used everywhere else, like content and
* list items (null uses device default). E.g. [your-project]/app/main/assets/fonts/[regular]
* @return The Builder instance so you can chain calls to it.
*/
public Builder typeface(@Nullable String medium, @Nullable String regular) {
if (medium != null) {
this.mediumFont = TypefaceHelper.get(this.context, medium);
if (this.mediumFont == null)
throw new IllegalArgumentException("No font asset found for " + medium);
}
if (regular != null) {
this.regularFont = TypefaceHelper.get(this.context, regular);
if (this.regularFont == null)
throw new IllegalArgumentException("No font asset found for " + regular);
}
return this;
}
LWQWallpaperControllerUnsplashImpl.java 文件源码
项目:quotograph
阅读 26
收藏 0
点赞 0
评论 0
@Override
public Typeface getTypeface() {
if (activeWallpaper == null) {
return null;
}
Fonts fontById = Fonts.findById((int) activeWallpaper.typefaceId);
return TypefaceHelper.get(LWQApplication.get(), fontById.getFileName());
}
FontMultiselectAdapter.java 文件源码
项目:quotograph
阅读 20
收藏 0
点赞 0
评论 0
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(this.context).inflate(R.layout.font_option_item, null);
}
Fonts font = allFonts[position];
CheckedTextView checkedTextView = (CheckedTextView) convertView.findViewById(R.id.ctv_font_option_item);
checkedTextView.setTypeface(TypefaceHelper.get(context, font.getFileName()));
checkedTextView.setText(font.getPrettyName(context));
checkedTextView.setChecked(selectedFonts.contains(String.valueOf(font.getId())));
return convertView;
}
MaterialDialog.java 文件源码
项目:EasyFrame
阅读 33
收藏 0
点赞 0
评论 0
/**
* Sets the fonts used in the dialog, by file names. This also uses TypefaceHelper in order
* to avoid any un-needed allocations (it recycles typefaces for you).
*
* @param medium The name of font in assets/fonts used on titles and action buttons (null uses device default). E.g. [your-project]/app/main/assets/fonts/[medium]
* @param regular The name of font in assets/fonts used everywhere else, like content and list items (null uses device default). E.g. [your-project]/app/main/assets/fonts/[regular]
* @return The Builder instance so you can chain calls to it.
*/
public Builder typeface(@Nullable String medium, @Nullable String regular) {
if (medium != null) {
this.mediumFont = TypefaceHelper.get(this.context, medium);
if (this.mediumFont == null)
throw new IllegalArgumentException("No font asset found for " + medium);
}
if (regular != null) {
this.regularFont = TypefaceHelper.get(this.context, regular);
if (this.regularFont == null)
throw new IllegalArgumentException("No font asset found for " + regular);
}
return this;
}
MaterialDialog.java 文件源码
项目:puautologin
阅读 28
收藏 0
点赞 0
评论 0
/**
* Sets the fonts used in the dialog, by file names. This also uses TypefaceHelper in order
* to avoid any un-needed allocations (it recycles typefaces for you).
*
* @param medium The name of font in assets/fonts, minus the extension (null uses device default). E.g. [your-project]/app/main/assets/fonts/[medium].ttf
* @param regular The name of font in assets/fonts, minus the extension (null uses device default). E.g. [your-project]/app/main/assets/fonts/[regular].ttf
* @return The Builder instance so you can chain calls to it.
*/
public Builder typeface(String medium, String regular) {
if (medium != null)
this.mediumFont = TypefaceHelper.get(this.context, medium);
if (regular != null)
this.regularFont = TypefaceHelper.get(this.context, regular);
this.useCustomFonts = true;
return this;
}