From 80cafcbb7531b68e9acfadcb17c331a7c684b649 Mon Sep 17 00:00:00 2001 From: linyuh Date: Thu, 28 Jun 2018 14:43:00 -0700 Subject: Make sure we have a host for the search fragment before loading data. Bug: 110941275 Test: None PiperOrigin-RevId: 202546724 Change-Id: If8ca1f57ac61288efc13da07cfc88cee72e170c7 --- .../dialer/searchfragment/list/NewSearchFragment.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java index 65ce87340..809f91775 100644 --- a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java +++ b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java @@ -121,11 +121,23 @@ public final class NewSearchFragment extends Fragment // the contacts in them). private final List directories = new ArrayList<>(); private final Runnable loaderCp2ContactsRunnable = - () -> getLoaderManager().restartLoader(CONTACTS_LOADER_ID, null, this); + () -> { + if (getHost() != null) { + getLoaderManager().restartLoader(CONTACTS_LOADER_ID, null, this); + } + }; private final Runnable loadNearbyPlacesRunnable = - () -> getLoaderManager().restartLoader(NEARBY_PLACES_LOADER_ID, null, this); + () -> { + if (getHost() != null) { + getLoaderManager().restartLoader(NEARBY_PLACES_LOADER_ID, null, this); + } + }; private final Runnable loadDirectoryContactsRunnable = - () -> getLoaderManager().restartLoader(DIRECTORY_CONTACTS_LOADER_ID, null, this); + () -> { + if (getHost() != null) { + getLoaderManager().restartLoader(DIRECTORY_CONTACTS_LOADER_ID, null, this); + } + }; private final Runnable capabilitiesUpdatedRunnable = () -> adapter.notifyDataSetChanged(); private Runnable updatePositionRunnable; -- cgit v1.2.3