[Android] Do not show dialogs if activity is finishing
Geoffrey Métais
git at videolan.org
Tue Nov 17 14:02:39 CET 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Nov 17 11:18:38 2015 +0100| [fe489a531fe356fc7005343bdab6504e55ba9b08] | committer: Geoffrey Métais
Do not show dialogs if activity is finishing
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=fe489a531fe356fc7005343bdab6504e55ba9b08
---
.../vlc/gui/video/VideoPlayerActivity.java | 40 ++++++++++----------
.../src/org/videolan/vlc/util/Permissions.java | 4 +-
2 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 9337a51..8560d2b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2039,27 +2039,29 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
i++;
}
- mAlertDialog = new AlertDialog.Builder(VideoPlayerActivity.this)
- .setTitle(titleId)
- .setSingleChoiceItems(nameList, listPosition, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int listPosition) {
- int trackID = -1;
- // Reverse map search...
- for (MediaPlayer.TrackDescription track : tracks) {
- if (idList[listPosition] == track.id) {
- trackID = track.id;
- break;
+ if (!isFinishing()) {
+ mAlertDialog = new AlertDialog.Builder(VideoPlayerActivity.this)
+ .setTitle(titleId)
+ .setSingleChoiceItems(nameList, listPosition, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int listPosition) {
+ int trackID = -1;
+ // Reverse map search...
+ for (MediaPlayer.TrackDescription track : tracks) {
+ if (idList[listPosition] == track.id) {
+ trackID = track.id;
+ break;
+ }
}
+ listener.onTrackSelected(trackID);
+ dialog.dismiss();
}
- listener.onTrackSelected(trackID);
- dialog.dismiss();
- }
- })
- .create();
- mAlertDialog.setCanceledOnTouchOutside(true);
- mAlertDialog.setOwnerActivity(VideoPlayerActivity.this);
- mAlertDialog.show();
+ })
+ .create();
+ mAlertDialog.setCanceledOnTouchOutside(true);
+ mAlertDialog.setOwnerActivity(VideoPlayerActivity.this);
+ mAlertDialog.show();
+ }
}
private void selectAudioTrack() {
diff --git a/vlc-android/src/org/videolan/vlc/util/Permissions.java b/vlc-android/src/org/videolan/vlc/util/Permissions.java
index 566db8d..6ffa989 100644
--- a/vlc-android/src/org/videolan/vlc/util/Permissions.java
+++ b/vlc-android/src/org/videolan/vlc/util/Permissions.java
@@ -87,13 +87,13 @@ public class Permissions {
private static Dialog sAlertDialog;
public static void showSettingsPermissionDialog(final Activity activity) {
- if (sAlertDialog != null && sAlertDialog.isShowing())
+ if (activity.isFinishing() || (sAlertDialog != null && sAlertDialog.isShowing()))
return;
sAlertDialog = createSettingsDialogCompat(activity);
}
public static void showStoragePermissionDialog(final Activity activity, boolean exit) {
- if (sAlertDialog != null && sAlertDialog.isShowing())
+ if (activity.isFinishing() || (sAlertDialog != null && sAlertDialog.isShowing()))
return;
if (activity instanceof AppCompatActivity)
sAlertDialog = createDialogCompat(activity, exit);
More information about the Android
mailing list