Commit 8c9029aa authored by Geoffrey Métais's avatar Geoffrey Métais

Check service connection in dialog cancel

parent 9bf8e30f
......@@ -2164,11 +2164,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
public void disconnect() {
if (mBound) {
mBound = false;
try {
mContext.unbindService(mServiceConnection);
} catch (IllegalArgumentException e) {
//Safety catch
}
mContext.unbindService(mServiceConnection);
}
}
......
......@@ -237,7 +237,8 @@ public class MediaUtils {
private static class DialogCallback extends BaseCallBack {
private final ProgressDialog dialog;
final private Runnable mRunnable;
private final Runnable mRunnable;
private boolean performAction = true;
private interface Runnable {
void run(PlaybackService service);
......@@ -254,7 +255,12 @@ public class MediaUtils {
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mClient.disconnect();
synchronized (this) {
if (performAction)
performAction = false;
else
mClient.disconnect();
}
}
});
mClient.connect();
......@@ -262,7 +268,12 @@ public class MediaUtils {
@Override
public void onConnected(PlaybackService service) {
mRunnable.run(service);
synchronized (this) {
if (performAction) {
performAction = false;
mRunnable.run(service);
}
}
dialog.cancel();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment