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 1111public class FontManager {
1212
1313 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 ) {
1523 case "1" -> ResourcesCompat .getFont (context , R .font .font_fira_code );
1624 case "2" -> ResourcesCompat .getFont (context , R .font .font_jetbrains_mono );
1725 case "3" -> ResourcesCompat .getFont (context , R .font .font_noto_sans_mono );
You can’t perform that action at this time.
0 commit comments