am f655a80c: Merge "Update TabLayout demo to use new APIs" into lmp-mr1-ub-dev
* commit 'f655a80cbe55d5d49cf128821a0e5d283b1daede':
Update TabLayout demo to use new APIs
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java
index 910322e..ef776e0 100644
--- a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java
@@ -21,6 +21,8 @@
import android.os.Bundle;
import android.support.design.widget.TabLayout;
+import android.support.design.widget.TabLayout.TabLayoutOnPageChangeListener;
+import android.support.design.widget.TabLayout.ViewPagerOnTabSelectedListener;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
@@ -59,8 +61,8 @@
mViewPager = (ViewPager) findViewById(R.id.tabs_viewpager);
mPagerAdapter = new CheesePagerAdapter();
mViewPager.setAdapter(mPagerAdapter);
- mViewPager.setOnPageChangeListener(mTabLayout.createOnPageChangeListener());
- mTabLayout.setOnTabSelectedListener(mTabListener);
+ mViewPager.setOnPageChangeListener(new TabLayoutOnPageChangeListener(mTabLayout));
+ mTabLayout.setOnTabSelectedListener(new ViewPagerOnTabSelectedListener(mViewPager));
setupButtons();
setupRadioGroup();
@@ -144,24 +146,6 @@
});
}
- private final TabLayout.OnTabSelectedListener
- mTabListener = new TabLayout.OnTabSelectedListener() {
- @Override
- public void onTabSelected(TabLayout.Tab tab) {
- mViewPager.setCurrentItem(tab.getPosition());
- }
-
- @Override
- public void onTabUnselected(TabLayout.Tab tab) {
- // no-op
- }
-
- @Override
- public void onTabReselected(TabLayout.Tab tab) {
- // no-op
- }
- };
-
private static class CheesePagerAdapter extends PagerAdapter {
private final ArrayList<CharSequence> mCheeses = new ArrayList<>();