[Android] Move the AudioBrowser to Tablayout
Jean-Baptiste Kempf
git at videolan.org
Mon Jun 15 11:45:22 CEST 2015
vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sat Jun 13 01:18:40 2015 +0200| [62c13ba69dfc7b2688c0e4238dbd6b8cd599e4bc] | committer: Geoffrey Métais
Move the AudioBrowser to Tablayout
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=62c13ba69dfc7b2688c0e4238dbd6b8cd599e4bc
---
vlc-android/res/layout/audio_browser.xml | 2 +-
.../vlc/gui/audio/AudioBrowserFragment.java | 36 ++++++++++++--------
2 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/vlc-android/res/layout/audio_browser.xml b/vlc-android/res/layout/audio_browser.xml
index 3f03e95..9d1beaa 100644
--- a/vlc-android/res/layout/audio_browser.xml
+++ b/vlc-android/res/layout/audio_browser.xml
@@ -5,7 +5,7 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent">
- <com.android.widget.SlidingTabLayout
+ <android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
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 8fa4421..3b2e7fa 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -28,6 +28,7 @@ import android.os.Handler;
import android.os.Message;
import android.support.design.widget.Snackbar;
import android.support.design.widget.FloatingActionButton;
+import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
@@ -48,8 +49,6 @@ import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.TextView;
-import com.android.widget.SlidingTabLayout;
-
import org.videolan.libvlc.Media;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.libvlc.util.MediaBrowser;
@@ -80,7 +79,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeRefreshLayout.OnRefreshListener, SlidingTabLayout.OnTabChangedListener, MediaBrowser.EventListener, IBrowser {
+public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeRefreshLayout.OnRefreshListener, MediaBrowser.EventListener, IBrowser {
public final static String TAG = "VLC/AudioBrowserFragment";
private MediaLibrary mMediaLibrary;
@@ -96,7 +95,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
private ConcurrentLinkedQueue<AudioBrowserListAdapter> mAdaptersToNotify = new ConcurrentLinkedQueue<AudioBrowserListAdapter>();
private ViewPager mViewPager;
- private SlidingTabLayout mSlidingTabLayout;
+ private TabLayout mSlidingTabLayout;
private TextView mEmptyView;
private List<View> mLists;
private FloatingActionButton mFabPlayShuffleAll;
@@ -165,10 +164,25 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
mViewPager.setAdapter(new AudioPagerAdapter(mLists, titles));
mViewPager.setOnTouchListener(mSwipeFilter);
- mSlidingTabLayout = (SlidingTabLayout) v.findViewById(R.id.sliding_tabs);
- mSlidingTabLayout.setCustomTabView(R.layout.tab_layout, R.id.tab_title);
- mSlidingTabLayout.setViewPager(mViewPager);
- mSlidingTabLayout.setOnTabChangedListener(this);
+
+ mSlidingTabLayout = (TabLayout) v.findViewById(R.id.sliding_tabs);
+ mSlidingTabLayout.setupWithViewPager(mViewPager);
+ mSlidingTabLayout.setTabMode(TabLayout.MODE_FIXED);
+
+ mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mSlidingTabLayout));
+ mSlidingTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
+ @Override
+ public void onTabSelected(TabLayout.Tab tab) {
+ updateEmptyView(tab.getPosition());
+ setFabPlayShuffleAllVisibility();
+ }
+
+ @Override
+ public void onTabUnselected(TabLayout.Tab tab) {}
+
+ @Override
+ public void onTabReselected(TabLayout.Tab tab) {}
+ });
songsList.setOnItemClickListener(songListener);
artistList.setOnItemClickListener(artistListListener);
@@ -597,12 +611,6 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
return getString(R.string.audio);
}
- @Override
- public void tabChanged(int position) {
- updateEmptyView(position);
- setFabPlayShuffleAllVisibility();
- }
-
private void updateEmptyView(int position) {
if (position == MODE_PLAYLIST){
mEmptyView.setVisibility(mPlaylistAdapter.isEmpty() ? View.VISIBLE : View.GONE);
More information about the Android
mailing list