diff options
Diffstat (limited to 'java/com/android/dialer/app')
-rw-r--r-- | java/com/android/dialer/app/calllog/CallLogFragment.java | 31 | ||||
-rw-r--r-- | java/com/android/dialer/app/list/ListsFragment.java | 10 |
2 files changed, 28 insertions, 13 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogFragment.java b/java/com/android/dialer/app/calllog/CallLogFragment.java index 4f5035fc6..7f635dbca 100644 --- a/java/com/android/dialer/app/calllog/CallLogFragment.java +++ b/java/com/android/dialer/app/calllog/CallLogFragment.java @@ -53,10 +53,10 @@ import com.android.dialer.app.calllog.calllogcache.CallLogCache; import com.android.dialer.app.contactinfo.ContactInfoCache; import com.android.dialer.app.contactinfo.ContactInfoCache.OnContactInfoChangedListener; import com.android.dialer.app.contactinfo.ExpirableCacheHeadlessFragment; -import com.android.dialer.app.list.ListsFragment; import com.android.dialer.app.voicemail.VoicemailPlaybackPresenter; import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler; import com.android.dialer.common.Assert; +import com.android.dialer.common.FragmentUtils; import com.android.dialer.common.LogUtil; import com.android.dialer.database.CallLogQueryHandler; import com.android.dialer.database.CallLogQueryHandler.Listener; @@ -344,9 +344,10 @@ public class CallLogFragment extends Fragment recyclerView, this, this, - activityType == CallLogAdapter.ACTIVITY_TYPE_DIALTACTS - ? (CallLogAdapter.OnActionModeStateChangedListener) getActivity() - : null, + // We aren't calling getParentUnsafe because CallLogActivity doesn't need to + // implement this listener + FragmentUtils.getParent( + this, CallLogAdapter.OnActionModeStateChangedListener.class), new CallLogCache(getActivity()), contactInfoCache, getVoicemailPlaybackPresenter(), @@ -479,7 +480,7 @@ public class CallLogFragment extends Fragment public void fetchCalls() { callLogQueryHandler.fetchCalls(callTypeFilter, dateLimit); if (!isCallLogActivity) { - ((ListsFragment) getParentFragment()).updateTabUnreadCounts(); + FragmentUtils.getParentUnsafe(this, CallLogFragmentListener.class).updateTabUnreadCounts(); } } @@ -616,7 +617,8 @@ public class CallLogFragment extends Fragment public void onVisible() { LogUtil.enterBlock("CallLogFragment.onPageSelected"); if (getActivity() != null && getActivity() instanceof HostInterface) { - ((HostInterface) getActivity()).enableFloatingButton(!isModalAlertVisible()); + FragmentUtils.getParentUnsafe(this, HostInterface.class) + .enableFloatingButton(!isModalAlertVisible()); } } @@ -638,7 +640,7 @@ public class CallLogFragment extends Fragment this, getUserVisibleHint()); getAdapter().notifyDataSetChanged(); - HostInterface hostInterface = (HostInterface) getActivity(); + HostInterface hostInterface = FragmentUtils.getParent(this, HostInterface.class); if (show) { recyclerView.setVisibility(View.GONE); modalAlertView.setVisibility(View.VISIBLE); @@ -659,7 +661,8 @@ public class CallLogFragment extends Fragment multiSelectUnSelectAllViewContent.setVisibility(show ? View.VISIBLE : View.GONE); multiSelectUnSelectAllViewContent.setAlpha(show ? 0 : 1); multiSelectUnSelectAllViewContent.animate().alpha(show ? 1 : 0).start(); - ((ListsFragment) getParentFragment()).showMultiSelectRemoveView(show); + FragmentUtils.getParentUnsafe(this, CallLogFragmentListener.class) + .showMultiSelectRemoveView(show); } @Override @@ -717,4 +720,16 @@ public class CallLogFragment extends Fragment refreshDataRequired = true; } } + + /** Useful callback for ListsFragment children to use to call into ListsFragment. */ + public interface CallLogFragmentListener { + + /** + * External method to update unread count because the unread count changes when the user expands + * a voicemail in the call log or when the user expands an unread call in the call history tab. + */ + void updateTabUnreadCounts(); + + void showMultiSelectRemoveView(boolean show); + } } diff --git a/java/com/android/dialer/app/list/ListsFragment.java b/java/com/android/dialer/app/list/ListsFragment.java index bbbf056bf..d314917ef 100644 --- a/java/com/android/dialer/app/list/ListsFragment.java +++ b/java/com/android/dialer/app/list/ListsFragment.java @@ -34,6 +34,7 @@ import android.view.ViewGroup; import com.android.contacts.common.list.ViewPagerTabs; import com.android.dialer.app.R; import com.android.dialer.app.calllog.CallLogFragment; +import com.android.dialer.app.calllog.CallLogFragment.CallLogFragmentListener; import com.android.dialer.app.calllog.CallLogNotificationsService; import com.android.dialer.app.calllog.VisualVoicemailCallLogFragment; import com.android.dialer.common.LogUtil; @@ -59,7 +60,8 @@ import java.util.ArrayList; * Contacts list. This will also eventually contain the logic that allows sliding the ViewPager * containing the lists up above the search bar and pin it against the top of the screen. */ -public class ListsFragment extends Fragment implements OnPageChangeListener, Listener { +public class ListsFragment extends Fragment + implements OnPageChangeListener, Listener, CallLogFragmentListener { private static final String TAG = "ListsFragment"; @@ -423,10 +425,7 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis return true; } - /** - * External method to update unread count because the unread count changes when the user expands a - * voicemail in the call log or when the user expands an unread call in the call history tab. - */ + @Override public void updateTabUnreadCounts() { if (callLogQueryHandler != null) { callLogQueryHandler.fetchMissedCallsUnreadCount(); @@ -450,6 +449,7 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis removeView.animate().alpha(show ? 1 : 0).start(); } + @Override public void showMultiSelectRemoveView(boolean show) { viewPagerTabs.setVisibility(show ? View.GONE : View.VISIBLE); viewPager.setEnableSwipingPages(!show); |