예제 #1
0
 /** Utility for common operation */
 @SuppressWarnings("unchecked")
 private <T extends Format> T getFormatMatching(Class klazz) {
   for (Format format : mFormatList) {
     if (klazz.isAssignableFrom(format.getClass())) {
       return (T) format;
     }
   }
   return null;
 }
예제 #2
0
  /**
   * Set text to the view that will be marked up, (note: {@link #setText(CharSequence)} etc is final
   * and thus cannot be overriden)
   */
  public final void setMarkupText(String text) {
    SpannableStringBuilder builder = new SpannableStringBuilder(text);

    for (Format format : mFormatList) {
      builder = format.format(this, builder);
    }

    setText(builder);
  }
예제 #3
0
 /** Utility for common operation */
 private void setTypefaceForClass(Typeface typeface, Class klazz) {
   Format format = getFormatMatching(klazz);
   if (format != null) {
     format.addCustomTypeface(typeface);
   }
 }