diff options
author | Yorke Lee <yorkelee@google.com> | 2014-04-16 16:08:56 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2014-04-16 16:10:01 -0700 |
commit | 0e8b0318a91143ad505cbf173a3f75a25a338696 (patch) | |
tree | f719ad7931a12e76716cb8d0f09c1154481c2af1 /src/com/android/dialer/calllog/CallLogActivity.java | |
parent | eea6a884c719f4926ed7e2f4d47ce7d18df81b48 (diff) |
Remove deprecated Actionbar tabs in CallLogActivity
Bug: 10510027
Change-Id: I05e9ee28b1bac74cf5f0dad349bce94659118fee
Diffstat (limited to 'src/com/android/dialer/calllog/CallLogActivity.java')
-rw-r--r-- | src/com/android/dialer/calllog/CallLogActivity.java | 67 |
1 files changed, 16 insertions, 51 deletions
diff --git a/src/com/android/dialer/calllog/CallLogActivity.java b/src/com/android/dialer/calllog/CallLogActivity.java index eb1f45e67..cdd0baff1 100644 --- a/src/com/android/dialer/calllog/CallLogActivity.java +++ b/src/com/android/dialer/calllog/CallLogActivity.java @@ -19,21 +19,18 @@ import android.app.ActionBar; import android.app.Activity; import android.app.Fragment; import android.app.FragmentManager; -import android.app.ActionBar.Tab; -import android.app.ActionBar.TabListener; -import android.app.FragmentTransaction; import android.content.Intent; import android.os.Bundle; import android.provider.CallLog.Calls; import android.support.v13.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; -import android.support.v4.view.ViewPager.OnPageChangeListener; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; +import com.android.dialer.list.ViewPagerTabs; public class CallLogActivity extends Activity { @@ -43,6 +40,8 @@ public class CallLogActivity extends Activity { private CallLogFragment mMissedCallsFragment; private CallLogFragment mVoicemailFragment; + private String[] mTabTitles; + private static final int TAB_INDEX_ALL = 0; private static final int TAB_INDEX_MISSED = 1; private static final int TAB_INDEX_VOICEMAIL = 2; @@ -71,44 +70,15 @@ public class CallLogActivity extends Activity { } @Override - public int getCount() { - return TAB_INDEX_COUNT; - } - } - - private final TabListener mTabListener = new TabListener() { - @Override - public void onTabUnselected(Tab tab, FragmentTransaction ft) { - } - - @Override - public void onTabSelected(Tab tab, FragmentTransaction ft) { - if (mViewPager != null && mViewPager.getCurrentItem() != tab.getPosition()) { - mViewPager.setCurrentItem(tab.getPosition(), true); - } + public CharSequence getPageTitle(int position) { + return mTabTitles[position]; } @Override - public void onTabReselected(Tab tab, FragmentTransaction ft) { - } - }; - - private final OnPageChangeListener mOnPageChangeListener = new OnPageChangeListener() { - - @Override - public void onPageScrolled( - int position, float positionOffset, int positionOffsetPixels) {} - - @Override - public void onPageSelected(int position) { - final ActionBar actionBar = getActionBar(); - actionBar.selectTab(actionBar.getTabAt(position)); - } - - @Override - public void onPageScrollStateChanged(int arg0) { + public int getCount() { + return TAB_INDEX_COUNT; } - }; + } @Override protected void onCreate(Bundle savedInstanceState) { @@ -118,20 +88,23 @@ public class CallLogActivity extends Activity { getWindow().setBackgroundDrawable(null); final ActionBar actionBar = getActionBar(); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); - addTab(actionBar, getString(R.string.call_log_all_title)); - addTab(actionBar, getString(R.string.call_log_missed_title)); - addTab(actionBar, getString(R.string.call_log_voicemail_title)); + mTabTitles = new String[TAB_INDEX_COUNT]; + mTabTitles[0] = getString(R.string.call_log_all_title); + mTabTitles[1] = getString(R.string.call_log_missed_title); + mTabTitles[2] = getString(R.string.call_log_voicemail_title); mViewPager = (ViewPager) findViewById(R.id.call_log_pager); + mViewPagerAdapter = new ViewPagerAdapter(getFragmentManager()); mViewPager.setAdapter(mViewPagerAdapter); - mViewPager.setOnPageChangeListener(mOnPageChangeListener); mViewPager.setOffscreenPageLimit(2); + + ViewPagerTabs tabs = (ViewPagerTabs) findViewById(R.id.viewpager_header); + tabs.setViewPager(mViewPager); } @Override @@ -167,12 +140,4 @@ public class CallLogActivity extends Activity { } return super.onOptionsItemSelected(item); } - - private void addTab(ActionBar actionBar, String title) { - final Tab tab = actionBar.newTab(); - tab.setContentDescription(title); - tab.setText(title); - tab.setTabListener(mTabListener); - actionBar.addTab(tab); - } }
\ No newline at end of file |