// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package uk.co.chrisjenx.calligraphy; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Typeface; import android.text.Editable; import android.text.Spannable; import android.text.SpannableString; import android.text.TextUtils; import android.text.TextWatcher; import android.util.AttributeSet; import android.util.TypedValue; import android.widget.TextView; // Referenced classes of package uk.co.chrisjenx.calligraphy: // CalligraphyConfig, TypefaceUtils public final class CalligraphyUtils { private static Boolean sToolbarCheck = null; private CalligraphyUtils() { } static void applyFontToTextView(Context context, TextView textview, CalligraphyConfig calligraphyconfig) { applyFontToTextView(context, textview, calligraphyconfig, false); } public static void applyFontToTextView(Context context, TextView textview, CalligraphyConfig calligraphyconfig, String s) { applyFontToTextView(context, textview, calligraphyconfig, s, false); } static void applyFontToTextView(Context context, TextView textview, CalligraphyConfig calligraphyconfig, String s, boolean flag) { while (context == null || textview == null || calligraphyconfig == null || !TextUtils.isEmpty(s) && applyFontToTextView(context, textview, s, flag)) { return; } applyFontToTextView(context, textview, calligraphyconfig, flag); } static void applyFontToTextView(Context context, TextView textview, CalligraphyConfig calligraphyconfig, boolean flag) { while (context == null || textview == null || calligraphyconfig == null || !calligraphyconfig.isFontSet()) { return; } applyFontToTextView(context, textview, calligraphyconfig.getFontPath(), flag); } public static boolean applyFontToTextView(Context context, TextView textview, String s) { return applyFontToTextView(context, textview, s, false); } static boolean applyFontToTextView(Context context, TextView textview, String s, boolean flag) { if (textview == null || context == null) { return false; } else { return applyFontToTextView(textview, TypefaceUtils.load(context.getAssets(), s), flag); } } public static boolean applyFontToTextView(TextView textview, Typeface typeface) { return applyFontToTextView(textview, typeface, false); } public static boolean applyFontToTextView(TextView textview, Typeface typeface, boolean flag) { if (textview == null || typeface == null) { return false; } textview.setPaintFlags(textview.getPaintFlags() | 0x80 | 1); textview.setTypeface(typeface); if (flag) { textview.setText(applyTypefaceSpan(textview.getText(), typeface), android.widget.TextView.BufferType.SPANNABLE); textview.addTextChangedListener(new TextWatcher(typeface) { final Typeface val$typeface; public void afterTextChanged(Editable editable) { CalligraphyUtils.applyTypefaceSpan(editable, typeface); } public void beforeTextChanged(CharSequence charsequence, int i, int j, int k) { } public void onTextChanged(CharSequence charsequence, int i, int j, int k) { } { typeface = typeface1; super(); } }); } return true; } public static CharSequence applyTypefaceSpan(CharSequence charsequence, Typeface typeface) { Object obj = charsequence; if (charsequence != null) { obj = charsequence; if (charsequence.length() > 0) { obj = charsequence; if (!(charsequence instanceof Spannable)) { obj = new SpannableString(charsequence); } ((Spannable)obj).setSpan(TypefaceUtils.getSpan(typeface), 0, ((CharSequence) (obj)).length(), 33); } } return ((CharSequence) (obj)); } static boolean canCheckForV7Toolbar() { if (sToolbarCheck == null) { try { Class.forName("android.support.v7.widget.Toolbar"); sToolbarCheck = Boolean.TRUE; } catch (ClassNotFoundException classnotfoundexception) { sToolbarCheck = Boolean.FALSE; } } return sToolbarCheck.booleanValue(); } static String pullFontPathFromStyle(Context context, AttributeSet attributeset, int i) { if (i == -1 || attributeset == null) { return null; } context = context.obtainStyledAttributes(attributeset, new int[] { i }); if (context == null) { break MISSING_BLOCK_LABEL_53; } boolean flag; attributeset = context.getString(0); flag = TextUtils.isEmpty(attributeset); if (!flag) { context.recycle(); return attributeset; } context.recycle(); _L2: return null; attributeset; context.recycle(); if (true) goto _L2; else goto _L1 _L1: attributeset; context.recycle(); throw attributeset; } static String pullFontPathFromTextAppearance(Context context, AttributeSet attributeset, int i) { if (i != -1 && attributeset != null) goto _L2; else goto _L1 _L1: return null; _L2: int j = -1; attributeset = context.obtainStyledAttributes(attributeset, new int[] { 0x1010034 }); if (attributeset != null) { try { j = attributeset.getResourceId(0, -1); } // Misplaced declaration of an exception variable catch (Context context) { attributeset.recycle(); return null; } finally { attributeset.recycle(); } attributeset.recycle(); } context = context.obtainStyledAttributes(j, new int[] { i }); if (context == null) goto _L1; else goto _L3 _L3: try { attributeset = context.getString(0); } // Misplaced declaration of an exception variable catch (AttributeSet attributeset) { context.recycle(); return null; } finally { context.recycle(); } context.recycle(); return attributeset; throw context; throw attributeset; } static String pullFontPathFromTheme(Context context, int i, int j) { Exception exception1; if (i == -1 || j == -1) { return null; } context = context.getTheme(); Object obj = new TypedValue(); context.resolveAttribute(i, ((TypedValue) (obj)), true); context = context.obtainStyledAttributes(((TypedValue) (obj)).resourceId, new int[] { j }); try { obj = context.getString(0); } catch (Exception exception) { context.recycle(); return null; } finally { context.recycle(); } context.recycle(); return ((String) (obj)); throw exception1; } static String pullFontPathFromTheme(Context context, int i, int j, int k) { if (i != -1 && k != -1) goto _L2; else goto _L1 _L1: return null; _L2: Object obj = context.getTheme(); TypedValue typedvalue = new TypedValue(); ((android.content.res.Resources.Theme) (obj)).resolveAttribute(i, typedvalue, true); obj = ((android.content.res.Resources.Theme) (obj)).obtainStyledAttributes(typedvalue.resourceId, new int[] { j }); try { i = ((TypedArray) (obj)).getResourceId(0, -1); } // Misplaced declaration of an exception variable catch (Context context) { ((TypedArray) (obj)).recycle(); return null; } finally { ((TypedArray) (obj)).recycle(); } ((TypedArray) (obj)).recycle(); if (i == -1) goto _L1; else goto _L3 _L3: context = context.obtainStyledAttributes(i, new int[] { k }); if (context == null) goto _L1; else goto _L4 _L4: Exception exception1; try { obj = context.getString(0); } catch (Exception exception) { context.recycle(); return null; } finally { context.recycle(); } context.recycle(); return ((String) (obj)); throw context; throw exception1; } static String pullFontPathFromView(Context context, AttributeSet attributeset, int i) { if (i == -1 || attributeset == null) { return null; } String s; try { s = context.getResources().getResourceEntryName(i); } // Misplaced declaration of an exception variable catch (Context context) { return null; } i = attributeset.getAttributeResourceValue(null, s, -1); if (i > 0) { return context.getString(i); } else { return attributeset.getAttributeValue(null, s); } } }