Prevent crash

pull/200/head
M66B 3 years ago
parent 7618dd949f
commit 86615c4a2d

@ -64,21 +64,24 @@ public class ApplicationEx extends Application
.commit(); // apply won't work here .commit(); // apply won't work here
} }
String tag = Locale.getDefault().toLanguageTag(); try {
if (!("de-AT".equals(tag) || "de-LI".equals(tag))) String language = prefs.getString("language", null);
tag = null; if (language != null) {
String language = prefs.getString("language", tag); if ("de-AT".equals(language) || "de-LI".equals(language))
if (language != null) { language = "de-DE";
if ("de-AT".equals(language) || "de-LI".equals(language)) Locale locale = Locale.forLanguageTag(language);
language = "de-DE"; Log.i("Set language=" + language + " locale=" + locale);
Locale locale = Locale.forLanguageTag(language); Locale.setDefault(locale);
EntityLog.log(context, "Set language=" + language + " locale=" + locale); Configuration config;
Locale.setDefault(locale); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q)
Configuration config = new Configuration(); config = new Configuration(context.getResources().getConfiguration());
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) else
config.setTo(context.getResources().getConfiguration()); config = new Configuration();
config.setLocale(locale); config.setLocale(locale);
return context.createConfigurationContext(config); return context.createConfigurationContext(config);
}
} catch (Throwable ex) {
Log.e(ex);
} }
return context; return context;

Loading…
Cancel
Save