[Android] run task directly if we already are in main thread

Geoffrey Métais git at videolan.org
Fri Jul 7 10:08:08 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jul  7 09:45:29 2017 +0200| [4621c3a5b78e4c525846947ce454d835c17c6e36] | committer: Geoffrey Métais

run task directly if we already are in main thread

> https://code.videolan.org/videolan/vlc-android/commit/4621c3a5b78e4c525846947ce454d835c17c6e36
---

 vlc-android/src/org/videolan/vlc/VLCApplication.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java b/vlc-android/src/org/videolan/vlc/VLCApplication.java
index 409139bc9..19d2de7c0 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -191,7 +191,10 @@ public class VLCApplication extends Application {
     }
 
     public static void runOnMainThread(Runnable runnable) {
-        instance.mHandler.post(runnable);
+        if (Looper.myLooper() == Looper.getMainLooper())
+            runnable.run();
+        else
+            instance.mHandler.post(runnable);
     }
 
     public static boolean removeTask(Runnable runnable) {



More information about the Android mailing list