[Android] Request the locale settings outside of the main thread

Nicolas Pomepuy git at videolan.org
Thu Apr 11 18:23:55 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Apr 11 13:00:22 2019 +0200| [4a6ff4ad5f47d2b7dd7148a2a3420526580f00ce] | committer: Geoffrey Métais

Request the locale settings outside of the main thread

> https://code.videolan.org/videolan/vlc-android/commit/4a6ff4ad5f47d2b7dd7148a2a3420526580f00ce
---

 vlc-android/src/org/videolan/vlc/VLCApplication.java | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java b/vlc-android/src/org/videolan/vlc/VLCApplication.java
index fc7ccb0d6..337c4c034 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -76,15 +76,22 @@ public class VLCApplication extends Application {
     @Override
     public void onCreate() {
         super.onCreate();
-        locale = Settings.INSTANCE.getInstance(instance).getString("set_locale", "");
 
-        // Set the locale for API < 24 and set application resources and direction for API >=24
-        setLocale(getAppContext());
+
         //Initiate Kotlinx Dispatchers in a thread to prevent ANR
         new Thread(new Runnable() {
             @Override
             public void run() {
 
+                locale = Settings.INSTANCE.getInstance(instance).getString("set_locale", "");
+                WorkersKt.runOnMainThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        // Set the locale for API < 24 and set application resources and direction for API >=24
+                        setLocale(getAppContext());
+                    }
+                });
+
                 WorkersKt.runIO(new Runnable() {
                     @TargetApi(Build.VERSION_CODES.O)
                     @Override



More information about the Android mailing list