Example #1
0
 private static void applyInternal(View view, Font font) {
   if (view instanceof ViewGroup) {
     final ViewGroup vg = (ViewGroup) view;
     final int childCount = vg.getChildCount();
     for (int i = 0; i < childCount; i++) {
       applyInternal(vg.getChildAt(i), font);
     }
   }
   if (view instanceof FontStyleProvider) {
     final FontStyleProvider provider = (FontStyleProvider) view;
     final int fontStyle = provider.getFontStyle();
     final String fontFamily = provider.getFontFamily();
     if (view.getTag(R.id.fontLoaderFont) == font
         && equals(view.getTag(R.id.fontLoaderFontStyle), fontStyle)
         && equals(view.getTag(R.id.fontLoaderFontFamily), fontFamily)) {
       return;
     }
     provider.setTypeface(font.getTypeface(fontFamily, fontStyle));
     view.setTag(R.id.fontLoaderFont, font);
     view.setTag(R.id.fontLoaderFontStyle, fontStyle);
     view.setTag(R.id.fontLoaderFontFamily, fontFamily);
   }
 }
Example #2
0
 private Typeface getTypeface(Font font, String fontFamily, int fontStyle) {
   font.mContext = getContext();
   return font.getTypeface(fontFamily, fontStyle);
 }