[Android] Handle OnDismiss event on option dialogs
Sébastien Toque
git at videolan.org
Mon Sep 3 07:19:45 CEST 2018
vlc-android | branch: master | Sébastien Toque <xilasz at gmail.com> | Mon Sep 3 06:54:50 2018 +0200| [de671248133052689b8ba040cbf2b4922d44fa8a] | committer: Sébastien Toque
Handle OnDismiss event on option dialogs
This fixes the status bar not dimmed when an option dialog is closed.
> https://code.videolan.org/videolan/vlc-android/commit/de671248133052689b8ba040cbf2b4922d44fa8a
---
.../videolan/vlc/gui/dialogs/AdvOptionsDialog.java | 19 +++----------------
.../vlc/gui/dialogs/DismissDialogFragment.java | 20 ++++++++++++++++++++
.../videolan/vlc/gui/dialogs/PickTimeFragment.java | 2 +-
.../vlc/gui/dialogs/PlaybackSpeedDialog.java | 2 +-
.../vlc/gui/dialogs/SelectChapterDialog.java | 2 +-
5 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
index 926f884d1..c83003b82 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
@@ -67,7 +67,7 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
-public class AdvOptionsDialog extends DialogFragment implements View.OnClickListener, PlaybackService.Client.Callback, View.OnFocusChangeListener, DialogInterface.OnKeyListener {
+public class AdvOptionsDialog extends DismissDialogFragment implements View.OnClickListener, PlaybackService.Client.Callback, View.OnFocusChangeListener, DialogInterface.OnKeyListener {
public final static String TAG = "VLC/AdvOptionsDialog";
public static final String MODE_KEY = "mode";
@@ -225,6 +225,8 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
default:
return;
}
+ if (newFragment instanceof DismissDialogFragment)
+ ((DismissDialogFragment)newFragment).setOnDismissListener(onDismissListener);
newFragment.show(getActivity().getSupportFragmentManager(), tag);
dismiss();
}
@@ -514,21 +516,6 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
mToast.show();
}
-
- private DialogInterface.OnDismissListener onDismissListener;
-
- public void setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
- this.onDismissListener = onDismissListener;
- }
-
- @Override
- public void onDismiss(DialogInterface dialog) {
- super.onDismiss(dialog);
- if (onDismissListener != null) {
- onDismissListener.onDismiss(dialog);
- }
- }
-
@Override
public void onStart() {
super.onStart();
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/DismissDialogFragment.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/DismissDialogFragment.java
new file mode 100644
index 000000000..175663c2e
--- /dev/null
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/DismissDialogFragment.java
@@ -0,0 +1,20 @@
+package org.videolan.vlc.gui.dialogs;
+
+import android.content.DialogInterface;
+import android.support.v4.app.DialogFragment;
+
+public class DismissDialogFragment extends DialogFragment {
+ protected DialogInterface.OnDismissListener onDismissListener;
+
+ public void setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
+ this.onDismissListener = onDismissListener;
+ }
+
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ super.onDismiss(dialog);
+ if (onDismissListener != null) {
+ onDismissListener.onDismiss(dialog);
+ }
+ }
+}
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java
index 03957f2de..286df07ad 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java
@@ -37,7 +37,7 @@ import org.videolan.vlc.gui.PlaybackServiceActivity;
import org.videolan.vlc.gui.PlaybackServiceFragment;
import org.videolan.vlc.gui.helpers.UiTools;
-public abstract class PickTimeFragment extends DialogFragment implements View.OnClickListener, View.OnFocusChangeListener,
+public abstract class PickTimeFragment extends DismissDialogFragment implements View.OnClickListener, View.OnFocusChangeListener,
PlaybackService.Client.Callback {
public final static String TAG = "VLC/PickTimeFragment";
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java
index e9940e7b2..a97282968 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java
@@ -40,7 +40,7 @@ import org.videolan.vlc.gui.helpers.OnRepeatListener;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.util.Strings;
-public class PlaybackSpeedDialog extends DialogFragment implements PlaybackService.Client.Callback {
+public class PlaybackSpeedDialog extends DismissDialogFragment implements PlaybackService.Client.Callback {
public final static String TAG = "VLC/PlaybackSpeedDialog";
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/SelectChapterDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/SelectChapterDialog.java
index 006f2d36e..5912db306 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/SelectChapterDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/SelectChapterDialog.java
@@ -45,7 +45,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class SelectChapterDialog extends DialogFragment implements PlaybackService.Client.Callback {
+public class SelectChapterDialog extends DismissDialogFragment implements PlaybackService.Client.Callback {
public final static String TAG = "VLC/SelectChapterDialog";
More information about the Android
mailing list