Update TabLayout demo to use new APIs

Depends-on: I7d944d2ebcd169c5c084000bd17f20da5c60e7ea

BUG: 20897298
Change-Id: I4976b16fc7d04e9facc9236fee4b5704c5b1ac0c
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<>();