[Android] Set app instance sooner
Geoffrey Métais
git at videolan.org
Mon May 22 15:29:50 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon May 22 09:35:12 2017 +0200| [49d0135b5411789538da68b7a39f001a05675b83] | committer: Geoffrey Métais
Set app instance sooner
> https://code.videolan.org/videolan/vlc-android/commit/49d0135b5411789538da68b7a39f001a05675b83
---
.../src/org/videolan/vlc/VLCApplication.java | 63 +++++++++++-----------
1 file changed, 31 insertions(+), 32 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java b/vlc-android/src/org/videolan/vlc/VLCApplication.java
index 9b72f41..ccb54ed 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -87,38 +87,38 @@ public class VLCApplication extends Application {
public void onCreate() {
synchronized (getClass()) {
super.onCreate();
+ instance = this;
+ }
- // Are we using advanced debugging - locale?
- mSettings = PreferenceManager.getDefaultSharedPreferences(this);
- String p = mSettings.getString("set_locale", "");
- if (!p.equals("")) {
- Locale locale;
- // workaround due to region code
- if(p.equals("zh-TW")) {
- locale = Locale.TRADITIONAL_CHINESE;
- } else if(p.startsWith("zh")) {
- locale = Locale.CHINA;
- } else if(p.equals("pt-BR")) {
- locale = new Locale("pt", "BR");
- } else if(p.equals("bn-IN") || p.startsWith("bn")) {
- locale = new Locale("bn", "IN");
- } else {
- /**
- * Avoid a crash of
- * java.lang.AssertionError: couldn't initialize LocaleData for locale
- * if the user enters nonsensical region codes.
- */
- if(p.contains("-"))
- p = p.substring(0, p.indexOf('-'));
- locale = new Locale(p);
- }
- Locale.setDefault(locale);
- Configuration config = new Configuration();
- config.locale = locale;
- getResources().updateConfiguration(config,
- getResources().getDisplayMetrics());
+ // Are we using advanced debugging - locale?
+ mSettings = PreferenceManager.getDefaultSharedPreferences(this);
+ String p = mSettings.getString("set_locale", "");
+ if (!p.equals("")) {
+ Locale locale;
+ // workaround due to region code
+ if(p.equals("zh-TW")) {
+ locale = Locale.TRADITIONAL_CHINESE;
+ } else if(p.startsWith("zh")) {
+ locale = Locale.CHINA;
+ } else if(p.equals("pt-BR")) {
+ locale = new Locale("pt", "BR");
+ } else if(p.equals("bn-IN") || p.startsWith("bn")) {
+ locale = new Locale("bn", "IN");
+ } else {
+ /**
+ * Avoid a crash of
+ * java.lang.AssertionError: couldn't initialize LocaleData for locale
+ * if the user enters nonsensical region codes.
+ */
+ if(p.contains("-"))
+ p = p.substring(0, p.indexOf('-'));
+ locale = new Locale(p);
}
- instance = this;
+ Locale.setDefault(locale);
+ Configuration config = new Configuration();
+ config.locale = locale;
+ getResources().updateConfiguration(config,
+ getResources().getDisplayMetrics());
}
runBackground(new Runnable() {
@@ -162,8 +162,7 @@ public class VLCApplication extends Application {
/**
* @return the main context of the Application
*/
- public static synchronized Context getAppContext()
- {
+ public static synchronized Context getAppContext() {
return instance;
}
More information about the Android
mailing list