diff options
author | Andrew Lee <anwlee@google.com> | 2015-03-18 18:59:45 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-18 18:59:46 +0000 |
commit | 3e7ee92cd04fbb37745799c329294d54fa6526a3 (patch) | |
tree | 72a324cba626b68489abb45cb0caddc81edb747f /src | |
parent | f7cef1a00e194ba3ed5b00a6640ea300dd6f97d4 (diff) | |
parent | dc4dd5e7da8407ac106263ae6b380b47ed536135 (diff) |
Merge "Clean up extra helper methods."
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/calllog/CallLogFragment.java | 77 |
1 files changed, 30 insertions, 47 deletions
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index 34dd137fb..f84d75b39 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -198,14 +198,14 @@ public class CallLogFragment extends ListFragment this, mLogLimit); mKeyguardManager = (KeyguardManager) getActivity().getSystemService(Context.KEYGUARD_SERVICE); - getActivity().getContentResolver().registerContentObserver(CallLog.CONTENT_URI, true, - mCallLogObserver); + getActivity().getContentResolver().registerContentObserver( + CallLog.CONTENT_URI, true, mCallLogObserver); getActivity().getContentResolver().registerContentObserver( ContactsContract.Contacts.CONTENT_URI, true, mContactsObserver); getActivity().getContentResolver().registerContentObserver( Status.CONTENT_URI, true, mVoicemailStatusObserver); setHasOptionsMenu(true); - updateCallList(mCallTypeFilter, mDateLimit); + fetchCalls(); mExpandedItemTranslationZ = getResources().getDimension(R.dimen.call_log_expanded_translation_z); @@ -270,13 +270,21 @@ public class CallLogFragment extends ListFragment */ @Override public void onVoicemailStatusFetched(Cursor statusCursor) { - if (getActivity() == null || getActivity().isFinishing()) { + Activity activity = getActivity(); + if (activity == null || activity.isFinishing()) { return; } updateVoicemailStatusMessage(statusCursor); - int activeSources = mVoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor); - setVoicemailSourcesAvailable(activeSources != 0); + // If there are any changes to the presence of active voicemail services, invalidate the + // options menu so that it will be updated. + boolean hasActiveVoicemailSources = + mVoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor) != 0; + if (mVoicemailSourcesAvailable != hasActiveVoicemailSources) { + mVoicemailSourcesAvailable = hasActiveVoicemailSources; + activity.invalidateOptionsMenu(); + } + mVoicemailStatusFetched = true; destroyEmptyLoaderIfAllDataFetched(); } @@ -288,18 +296,6 @@ public class CallLogFragment extends ListFragment } } - /** Sets whether there are any voicemail sources available in the platform. */ - private void setVoicemailSourcesAvailable(boolean voicemailSourcesAvailable) { - if (mVoicemailSourcesAvailable == voicemailSourcesAvailable) return; - mVoicemailSourcesAvailable = voicemailSourcesAvailable; - - Activity activity = getActivity(); - if (activity != null) { - // This is so that the options menu content is updated. - activity.invalidateOptionsMenu(); - } - } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { View view = inflater.inflate(R.layout.call_log_fragment, container, false); @@ -389,7 +385,8 @@ public class CallLogFragment extends ListFragment @Override public void onStop() { super.onStop(); - updateOnExit(); + + updateOnTransition(false /* onEntry */); } @Override @@ -418,19 +415,6 @@ public class CallLogFragment extends ListFragment mCallLogQueryHandler.fetchCalls(mCallTypeFilter, mDateLimit); } - public void startCallsQuery() { - mAdapter.setLoading(true); - mCallLogQueryHandler.fetchCalls(mCallTypeFilter, mDateLimit); - } - - private void startVoicemailStatusQuery() { - mCallLogQueryHandler.fetchVoicemailStatus(); - } - - private void updateCallList(int filterType, long dateLimit) { - mCallLogQueryHandler.fetchCalls(filterType, dateLimit); - } - private void updateEmptyMessage(int filterType) { final int messageId; switch (filterType) { @@ -461,7 +445,7 @@ public class CallLogFragment extends ListFragment if (mMenuVisible != menuVisible) { mMenuVisible = menuVisible; if (!menuVisible) { - updateOnExit(); + updateOnTransition(false /* onEntry */); } else if (isResumed()) { refreshData(); } @@ -475,24 +459,23 @@ public class CallLogFragment extends ListFragment // Mark all entries in the contact info cache as out of date, so they will be looked up // again once being shown. mAdapter.invalidateCache(); - startCallsQuery(); - startVoicemailStatusQuery(); - updateOnEntry(); - mRefreshDataRequired = false; - } - } + mAdapter.setLoading(true); - /** Updates call data and notification state while leaving the call log tab. */ - private void updateOnExit() { - updateOnTransition(false); - } + fetchCalls(); + mCallLogQueryHandler.fetchVoicemailStatus(); - /** Updates call data and notification state while entering the call log tab. */ - private void updateOnEntry() { - updateOnTransition(true); + updateOnTransition(true /* onEntry */); + mRefreshDataRequired = false; + } } - // TODO: Move to CallLogActivity + /** + * Updates the call data and notification state on entering or leaving the call log tab. + * + * If we are leaving the call log tab, mark all the missed calls as read. + * + * TODO: Move to CallLogActivity + */ private void updateOnTransition(boolean onEntry) { // We don't want to update any call data when keyguard is on because the user has likely not // seen the new calls yet. |