File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
app/src/main/java/com/d4rk/androidtutorials/java/utils Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 11
11
public class FontManager {
12
12
13
13
public static Typeface getMonospaceFont (Context context , SharedPreferences prefs ) {
14
- return switch (prefs .getString (context .getString (R .string .key_monospace_font ), "0" )) {
14
+ String key = context .getString (R .string .key_monospace_font );
15
+ String font ;
16
+ try {
17
+ font = prefs .getString (key , "0" );
18
+ } catch (ClassCastException e ) {
19
+ prefs .edit ().remove (key ).apply ();
20
+ font = "0" ;
21
+ }
22
+ return switch (font ) {
15
23
case "1" -> ResourcesCompat .getFont (context , R .font .font_fira_code );
16
24
case "2" -> ResourcesCompat .getFont (context , R .font .font_jetbrains_mono );
17
25
case "3" -> ResourcesCompat .getFont (context , R .font .font_noto_sans_mono );
You can’t perform that action at this time.
0 commit comments