[Android] No action from adv fragment if it's detached

Geoffrey Métais git at videolan.org
Mon May 25 10:27:28 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon May 25 10:26:51 2015 +0200| [173bd2c62aedc59be69a7708d2d2bed292e1280b] | committer: Geoffrey Métais

No action from adv fragment if it's detached

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=173bd2c62aedc59be69a7708d2d2bed292e1280b
---

 .../org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java    |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 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 97a415a..5d75edc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
@@ -338,19 +338,22 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
         @Override
         public void handleMessage(Message msg) {
             String text = null;
+            AdvOptionsDialog owner = getOwner();
+            if (owner == null || owner.isDetached())
+                return;
             switch (msg.what) {
                 case SPEED_TEXT:
                     text = (String) msg.obj;
-                    getOwner().mSpeedTv.setText(text);
+                    owner.mSpeedTv.setText(text);
                     break;
                 case TOGGLE_CANCEL:
-                    getOwner().mSleepCancel.setVisibility(VLCApplication.sPlayerSleepTime == null ? View.GONE : View.VISIBLE);
+                    owner.mSleepCancel.setVisibility(VLCApplication.sPlayerSleepTime == null ? View.GONE : View.VISIBLE);
                 case SLEEP_TEXT:
                     if (VLCApplication.sPlayerSleepTime != null)
-                        text = DateFormat.getTimeFormat(getOwner().mSleepTime.getContext()).format(VLCApplication.sPlayerSleepTime.getTime());
+                        text = DateFormat.getTimeFormat(owner.mSleepTime.getContext()).format(VLCApplication.sPlayerSleepTime.getTime());
                     if (text == null)
-                        text = getOwner().getString(R.string.sleep_time_not_set);
-                    getOwner().mSleepTime.setText(text);
+                        text = owner.getString(R.string.sleep_time_not_set);
+                    owner.mSleepTime.setText(text);
                     break;
                 case DIALOG_LISTENER:
                     DialogFragment newFragment = (DialogFragment) msg.obj;



More information about the Android mailing list