mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-20 14:19:08 +00:00
avoid repeated checks for custom typeface when there is none
This commit is contained in:
parent
789b533358
commit
cde1a70427
1 changed files with 4 additions and 1 deletions
|
@ -198,6 +198,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
// static cache for background images to avoid potentially slow reload on every settings reload
|
||||
private final static Drawable[] sCachedBackgroundImages = new Drawable[4];
|
||||
private static Typeface sCachedTypeface;
|
||||
private static boolean sCustomTypefaceLoaded; // to avoid repeatedly checking custom typeface file when there is no custom typeface
|
||||
private Map<String, Integer> mCustomToolbarKeyCodes = null;
|
||||
private Map<String, Integer> mCustomToolbarLongpressCodes = null;
|
||||
|
||||
|
@ -738,15 +739,17 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
|
||||
@Nullable
|
||||
public Typeface getCustomTypeface() {
|
||||
if (sCachedTypeface == null) {
|
||||
if (!sCustomTypefaceLoaded) {
|
||||
try {
|
||||
sCachedTypeface = Typeface.createFromFile(getCustomFontFile(mContext));
|
||||
} catch (Exception e) { }
|
||||
}
|
||||
sCustomTypefaceLoaded = true;
|
||||
return sCachedTypeface;
|
||||
}
|
||||
|
||||
public static void clearCachedTypeface() {
|
||||
sCachedTypeface = null;
|
||||
sCustomTypefaceLoaded = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue