Commit 7361d5b1 authored by Geoffrey Métais's avatar Geoffrey Métais

Directly handle ViewPager.OnPageChangeListener

parent e6b09c01
...@@ -77,7 +77,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; ...@@ -77,7 +77,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeRefreshLayout.OnRefreshListener, MediaBrowser.EventListener, IBrowser { public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeRefreshLayout.OnRefreshListener, MediaBrowser.EventListener, IBrowser, ViewPager.OnPageChangeListener {
public final static String TAG = "VLC/AudioBrowserFragment"; public final static String TAG = "VLC/AudioBrowserFragment";
private MediaBrowser mMediaBrowser; private MediaBrowser mMediaBrowser;
...@@ -161,23 +161,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR ...@@ -161,23 +161,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
mTabLayout = (TabLayout) v.findViewById(R.id.sliding_tabs); mTabLayout = (TabLayout) v.findViewById(R.id.sliding_tabs);
mTabLayout.setupWithViewPager(mViewPager); mTabLayout.setupWithViewPager(mViewPager);
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout)); mViewPager.addOnPageChangeListener(this);
mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
mViewPager.setCurrentItem(tab.getPosition());
updateEmptyView(tab.getPosition());
setFabPlayShuffleAllVisibility();
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {}
@Override
public void onTabReselected(TabLayout.Tab tab) {
mViewPager.setCurrentItem(tab.getPosition());
}
});
songsList.setOnItemClickListener(songListener); songsList.setOnItemClickListener(songListener);
artistList.setOnItemClickListener(artistListListener); artistList.setOnItemClickListener(artistListListener);
...@@ -654,6 +638,26 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR ...@@ -654,6 +638,26 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
mMainActivity.sendTextInfo(info, progress, max); mMainActivity.sendTextInfo(info, progress, max);
} }
TabLayout.TabLayoutOnPageChangeListener tcl = new TabLayout.TabLayoutOnPageChangeListener(mTabLayout);
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
tcl.onPageScrolled(position, positionOffset, positionOffsetPixels);
}
@Override
public void onPageSelected(int position) {
mViewPager.setCurrentItem(position);
updateEmptyView(position);
setFabPlayShuffleAllVisibility();
tcl.onPageSelected(position);
}
@Override
public void onPageScrollStateChanged(int state) {
tcl.onPageScrollStateChanged(state);
}
private static class AudioBrowserHandler extends WeakHandler<AudioBrowserFragment> { private static class AudioBrowserHandler extends WeakHandler<AudioBrowserFragment> {
public AudioBrowserHandler(AudioBrowserFragment owner) { public AudioBrowserHandler(AudioBrowserFragment owner) {
super(owner); super(owner);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment