[Android] Fix video restore

Geoffrey Métais git at videolan.org
Mon Feb 29 12:01:28 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 29 12:00:07 2016 +0100| [c63a7cb8d64c384458bdd226a83c583b30260f21] | committer: Geoffrey Métais

Fix video restore

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

 .../vlc/gui/video/VideoPlayerActivity.java         | 23 +++++++++-------------
 1 file changed, 9 insertions(+), 14 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 444ef7c..78ee33b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -110,6 +110,7 @@ import org.videolan.vlc.gui.helpers.OnRepeatListener;
 import org.videolan.vlc.gui.helpers.SwipeDragItemTouchHelperCallback;
 import org.videolan.vlc.gui.preferences.PreferencesActivity;
 import org.videolan.vlc.gui.preferences.PreferencesUi;
+import org.videolan.vlc.gui.tv.audioplayer.AudioPlayerActivity;
 import org.videolan.vlc.interfaces.IDelayController;
 import org.videolan.vlc.media.MediaDatabase;
 import org.videolan.vlc.media.MediaWrapper;
@@ -502,7 +503,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     @Override
     protected void onResume() {
         super.onResume();
-        mSwitchingView = false;
 
         /*
          * Set listeners here to avoid NPE when activity is closing
@@ -634,7 +634,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         if (mAlertDialog != null && mAlertDialog.isShowing())
             mAlertDialog.dismiss();
         if (!isFinishing() && mSettings.getBoolean(PreferencesActivity.VIDEO_BACKGROUND, false)) {
-            Util.commitPreferences(mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, true));
             switchToAudioMode(false);
         }
         stopPlayback();
@@ -1634,18 +1633,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             return;
         mSwitchingView = true;
         // Show the MainActivity if it is not in background.
-        if (showUI && getIntent().getAction() != null
-            && getIntent().getAction().equals(Intent.ACTION_VIEW)) {
-            Intent i = new Intent(this, MainActivity.class);
-            if (!Util.isCallable(i)){
-                try {
-                    i = new Intent(this, Class.forName("org.videolan.vlc.gui.tv.audioplayer.AudioPlayerActivity"));
-                } catch (ClassNotFoundException e) {
-                    return;
-                }
-            }
+        if (showUI) {
+            Intent i = new Intent(this, VLCApplication.showTvUi() ? AudioPlayerActivity.class : MainActivity.class);
             startActivity(i);
-        }
+        } else
+            Util.commitPreferences(mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, true));
         exitOK();
     }
 
@@ -3153,7 +3145,10 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     @Override
     public void onConnected(PlaybackService service) {
         mService = service;
-        mHandler.sendEmptyMessage(START_PLAYBACK);
+        if (!mSwitchingView)
+            mHandler.sendEmptyMessage(START_PLAYBACK);
+        mSwitchingView = false;
+        Util.commitPreferences(mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, false));
     }
 
     @Override



More information about the Android mailing list