summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-11-05 12:00:20 -0800
committerYorke Lee <yorkelee@google.com>2014-11-06 09:55:47 -0800
commitd93c149f4da67aa6dbbbc58f33d1f7c7db7a7068 (patch)
treed2b228be9686a26f70c29d5df45d09efde49ff55
parente6b0084dde5ae729584095cfe17bbc13eac6e5b7 (diff)
Fix for "Clear call log" menu item showing up incorrectly.
The fragment member variables were being lost on rotation because the FragmentManager does not call getItem on rotation. Fix the way we save the fragments into member variables to ensure that those references are always up to date so that mAllCallsFragment is not null after rotation. Bug: 17478780 Change-Id: I5a0c070273f2d86864afd96c6bb6551bcd0d1aa4
-rw-r--r--src/com/android/dialer/calllog/CallLogActivity.java31
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 c7862aee6..ab61f486c 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;
@@ -81,19 +82,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];
}
@@ -186,9 +202,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());
}