From 053b9c7a4b2662588706211fd8aa1f8a03ec2901 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Thu, 18 Jun 2015 18:19:20 -0700 Subject: Rewrite of MediaPlayer logic. + Control MediaPlayer instance more tightly. Wait until prepareContent to initialize instance. Release MediaPlayer when it is no longer needed. + Instead of using isFinishing, check explicitly for orientation change to know whether to release MediaPlayer. + Change Presenter to singleton, to address audio change wonkiness. + Only create a Presenter if the call log fragment shows voicemail. + ... fixing a variety of cases. - Temporarily disable proximity sensor until blocking issue is fixed. Bug: 21856243 Change-Id: Ic06e98bb5278467c3cce726a06b6cf3d855861a2 --- src/com/android/dialer/calllog/CallLogAdapter.java | 6 ++++-- .../android/dialer/calllog/CallLogFragment.java | 23 ++++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'src/com/android/dialer/calllog') diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 4304002da..bd478bd38 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -116,8 +116,10 @@ public class CallLogAdapter extends GroupingListAdapter return; } - // Always reset the voicemail playback state on expand or collapse. - mVoicemailPlaybackPresenter.reset(); + if (mVoicemailPlaybackPresenter != null) { + // Always reset the voicemail playback state on expand or collapse. + mVoicemailPlaybackPresenter.reset(); + } if (viewHolder.getAdapterPosition() == mCurrentlyExpandedPosition) { // Hide actions, if the clicked item is the expanded item. diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index 0f19f1491..21ea97ea6 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -187,7 +187,10 @@ public class CallLogFragment extends Fragment resolver.registerContentObserver(Status.CONTENT_URI, true, mVoicemailStatusObserver); setHasOptionsMenu(true); - mVoicemailPlaybackPresenter = new VoicemailPlaybackPresenter(activity, state); + if (mCallTypeFilter == Calls.VOICEMAIL_TYPE) { + mVoicemailPlaybackPresenter = VoicemailPlaybackPresenter + .getInstance(activity, state); + } } /** Called by the CallLogQueryHandler when the list of calls has been fetched or updated. */ @@ -321,23 +324,28 @@ public class CallLogFragment extends Fragment @Override public void onPause() { - mVoicemailPlaybackPresenter.onPause(getActivity().isFinishing()); + if (mVoicemailPlaybackPresenter != null) { + mVoicemailPlaybackPresenter.onPause(); + } mAdapter.pauseCache(); super.onPause(); } @Override public void onStop() { - super.onStop(); - updateOnTransition(false /* onEntry */); + + super.onStop(); } @Override public void onDestroy() { mAdapter.pauseCache(); mAdapter.changeCursor(null); - mVoicemailPlaybackPresenter.onDestroy(getActivity().isFinishing()); + + if (mVoicemailPlaybackPresenter != null) { + mVoicemailPlaybackPresenter.onDestroy(); + } getActivity().getContentResolver().unregisterContentObserver(mCallLogObserver); getActivity().getContentResolver().unregisterContentObserver(mContactsObserver); @@ -353,7 +361,10 @@ public class CallLogFragment extends Fragment outState.putLong(KEY_DATE_LIMIT, mDateLimit); mAdapter.onSaveInstanceState(outState); - mVoicemailPlaybackPresenter.onSaveInstanceState(outState); + + if (mVoicemailPlaybackPresenter != null) { + mVoicemailPlaybackPresenter.onSaveInstanceState(outState); + } } @Override -- cgit v1.2.3