[Android] Synchronize client connection

Geoffrey Métais git at videolan.org
Thu Jun 9 11:42:22 CEST 2016


vlc-android | branch: 2.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jun  9 11:08:41 2016 +0200| [29f389f3a2fd149ac1249aac01c4de7bb8ef4dd4] | committer: Geoffrey Métais

Synchronize client connection

(cherry picked from commit 1af07e5d2c33b10c065e9add5ef07eb554dc6f5a)

> https://code.videolan.org/videolan/vlc-android/commit/29f389f3a2fd149ac1249aac01c4de7bb8ef4dd4
---

 vlc-android/src/org/videolan/vlc/media/MediaUtils.java | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/media/MediaUtils.java b/vlc-android/src/org/videolan/vlc/media/MediaUtils.java
index 5f71c17..8094bc8 100644
--- a/vlc-android/src/org/videolan/vlc/media/MediaUtils.java
+++ b/vlc-android/src/org/videolan/vlc/media/MediaUtils.java
@@ -238,7 +238,6 @@ public class MediaUtils {
     private static class DialogCallback extends BaseCallBack {
         private final ProgressDialog dialog;
         private final Runnable mRunnable;
-        private boolean performAction = true;
 
         private interface Runnable {
             void run(PlaybackService service);
@@ -256,23 +255,19 @@ public class MediaUtils {
                 @Override
                 public void onCancel(DialogInterface dialog) {
                     synchronized (this) {
-                        if (performAction)
-                            performAction = false;
-                        else
-                            mClient.disconnect();
+                        mClient.disconnect();
                     }
                 }
             });
-            mClient.connect();
+            synchronized (this) {
+                mClient.connect();
+            }
         }
 
         @Override
         public void onConnected(PlaybackService service) {
             synchronized (this) {
-                if (performAction) {
-                    performAction = false;
-                    mRunnable.run(service);
-                }
+                mRunnable.run(service);
             }
             dialog.cancel();
         }



More information about the Android mailing list