mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-06 14:50:14 +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
|
// static cache for background images to avoid potentially slow reload on every settings reload
|
||||||
private final static Drawable[] sCachedBackgroundImages = new Drawable[4];
|
private final static Drawable[] sCachedBackgroundImages = new Drawable[4];
|
||||||
private static Typeface sCachedTypeface;
|
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> mCustomToolbarKeyCodes = null;
|
||||||
private Map<String, Integer> mCustomToolbarLongpressCodes = null;
|
private Map<String, Integer> mCustomToolbarLongpressCodes = null;
|
||||||
|
|
||||||
|
@ -738,15 +739,17 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Typeface getCustomTypeface() {
|
public Typeface getCustomTypeface() {
|
||||||
if (sCachedTypeface == null) {
|
if (!sCustomTypefaceLoaded) {
|
||||||
try {
|
try {
|
||||||
sCachedTypeface = Typeface.createFromFile(getCustomFontFile(mContext));
|
sCachedTypeface = Typeface.createFromFile(getCustomFontFile(mContext));
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) { }
|
||||||
}
|
}
|
||||||
|
sCustomTypefaceLoaded = true;
|
||||||
return sCachedTypeface;
|
return sCachedTypeface;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearCachedTypeface() {
|
public static void clearCachedTypeface() {
|
||||||
sCachedTypeface = null;
|
sCachedTypeface = null;
|
||||||
|
sCustomTypefaceLoaded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue