diff options
author | Yorke Lee <yorkelee@google.com> | 2014-11-06 20:12:45 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-11-06 20:12:46 +0000 |
commit | 99d00ab018325ebfa86206e847d48068065cdd9d (patch) | |
tree | 21c53e170f1a6180a51e1a71b2025a0804f5c29b /src/com/android/dialer/calllog/CallLogActivity.java | |
parent | b48f64c8dc3a7b17801222fe3be2c584054dcb66 (diff) | |
parent | d93c149f4da67aa6dbbbc58f33d1f7c7db7a7068 (diff) |
Merge "Fix for "Clear call log" menu item showing up incorrectly." into lmp-mr1-dev
Diffstat (limited to 'src/com/android/dialer/calllog/CallLogActivity.java')
-rw-r--r-- | src/com/android/dialer/calllog/CallLogActivity.java | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/com/android/dialer/calllog/CallLogActivity.java b/src/com/android/dialer/calllog/CallLogActivity.java index 1131b0ee8..33e72bc12 100644 --- a/src/com/android/dialer/calllog/CallLogActivity.java +++ b/src/com/android/dialer/calllog/CallLogActivity.java @@ -31,6 +31,7 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.MotionEvent; +import android.view.ViewGroup; import com.android.contacts.common.interactions.TouchPointManager; import com.android.contacts.common.list.ViewPagerTabs; @@ -83,19 +84,34 @@ public class CallLogActivity extends Activity implements CallLogQueryHandler.Lis public Fragment getItem(int position) { switch (position) { case TAB_INDEX_ALL: - mAllCallsFragment = new CallLogFragment(CallLogQueryHandler.CALL_TYPE_ALL); - return mAllCallsFragment; + return new CallLogFragment(CallLogQueryHandler.CALL_TYPE_ALL); case TAB_INDEX_MISSED: - mMissedCallsFragment = new CallLogFragment(Calls.MISSED_TYPE); - return mMissedCallsFragment; + return new CallLogFragment(Calls.MISSED_TYPE); case TAB_INDEX_VOICEMAIL: - mVoicemailFragment = new CallLogFragment(Calls.VOICEMAIL_TYPE); - return mVoicemailFragment; + return new CallLogFragment(Calls.VOICEMAIL_TYPE); } throw new IllegalStateException("No fragment at position " + position); } @Override + public Object instantiateItem(ViewGroup container, int position) { + final CallLogFragment fragment = + (CallLogFragment) super.instantiateItem(container, position); + switch (position) { + case TAB_INDEX_ALL: + mAllCallsFragment = fragment; + break; + case TAB_INDEX_MISSED: + mMissedCallsFragment = fragment; + break; + case TAB_INDEX_VOICEMAIL: + mVoicemailFragment = fragment; + break; + } + return fragment; + } + + @Override public CharSequence getPageTitle(int position) { return mTabTitles[position]; } @@ -189,9 +205,8 @@ public class CallLogActivity extends Activity implements CallLogQueryHandler.Lis @Override public boolean onPrepareOptionsMenu(Menu menu) { final MenuItem itemDeleteAll = menu.findItem(R.id.delete_all); - - // If onPrepareOptionsMenu is called before fragments loaded. Don't do anything. if (mAllCallsFragment != null && itemDeleteAll != null) { + // If onPrepareOptionsMenu is called before fragments are loaded, don't do anything. final CallLogAdapter adapter = mAllCallsFragment.getAdapter(); itemDeleteAll.setVisible(adapter != null && !adapter.isEmpty()); } |