[Android] Save selected audio tab

Geoffrey Métais git at videolan.org
Wed Jan 31 11:13:29 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 31 11:13:09 2018 +0100| [5c14f14f8b7cea418bda73f7fdf19aea8724d979] | committer: Geoffrey Métais

Save selected audio tab

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

 vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java | 2 ++
 vlc-android/src/org/videolan/vlc/util/Constants.java                 | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index c7e9fb9a1..bd46c1df5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -137,6 +137,7 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefre
         };
         mViewPager.setOffscreenPageLimit(MODE_TOTAL - 1);
         mViewPager.setAdapter(new AudioPagerAdapter(mLists, titles));
+        mViewPager.setCurrentItem(VLCApplication.getSettings().getInt(Constants.KEY_AUDIO_CURRENT_TAB, 0));
         final RecyclerView.RecycledViewPool rvp = new RecyclerView.RecycledViewPool();
         for (int i = 0; i< MODE_TOTAL; ++i) {
             final LinearLayoutManager llm = new LinearLayoutManager(getActivity());
@@ -421,6 +422,7 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefre
     public void onTabSelected(TabLayout.Tab tab) {
         getActivity().supportInvalidateOptionsMenu();
         mFastScroller.setRecyclerView(mLists[tab.getPosition()]);
+        VLCApplication.getSettings().edit().putInt(Constants.KEY_AUDIO_CURRENT_TAB, tab.getPosition()).apply();
     }
 
     @Override
diff --git a/vlc-android/src/org/videolan/vlc/util/Constants.java b/vlc-android/src/org/videolan/vlc/util/Constants.java
index 3fd170298..bc1ae73af 100644
--- a/vlc-android/src/org/videolan/vlc/util/Constants.java
+++ b/vlc-android/src/org/videolan/vlc/util/Constants.java
@@ -85,4 +85,7 @@ public class Constants {
 
     // Preferences
     public final static String KEY_ARTISTS_SHOW_ALL = "artists_show_all";
+
+    // AUDIO category
+    public final static String KEY_AUDIO_CURRENT_TAB = "key_audio_current_tab";
 }



More information about the Android mailing list