[Android] Fix rotation for media info fragment

Geoffrey Métais git at videolan.org
Mon Apr 27 15:04:33 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Apr 27 12:00:34 2015 +0200| [8fbbaa5a6bd9f8ed50ae0e41ff842891d62e1481] | committer: Geoffrey Métais

Fix rotation for media info fragment

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

 .../org/videolan/vlc/gui/video/MediaInfoFragment.java   |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
index 43fb511..610a0e2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
@@ -60,6 +60,8 @@ public class MediaInfoFragment extends ListFragment {
 
     public final static String TAG = "VLC/MediaInfoFragment";
 
+    public final static String ITEM_KEY = "key_item";
+
     private MediaWrapper mItem;
     private Bitmap mImage;
     private TextView mLengthView;
@@ -79,6 +81,13 @@ public class MediaInfoFragment extends ListFragment {
     ExecutorService mThreadPoolExecutor;
 
     @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        if (savedInstanceState != null)
+            mItem = savedInstanceState.getParcelable(ITEM_KEY);
+    }
+
+    @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         View v = inflater.inflate(R.layout.media_info, container, false);
@@ -143,6 +152,12 @@ public class MediaInfoFragment extends ListFragment {
             mThreadPoolExecutor.shutdownNow();
     }
 
+    @Override
+    public void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putParcelable(ITEM_KEY, mItem);
+    }
+
     public void setMediaLocation(String MRL) {
         if (MRL == null)
             return;



More information about the Android mailing list