From 79a407ee27e6c8f6447f3a8c71ae2c7f6b33f591 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Wed, 25 Apr 2018 01:53:47 -0700 Subject: Show clear frequents option in the toolbar if there are suggested contacts. Bug: 36841782 Test: SpeedDialAdapterTest PiperOrigin-RevId: 194210091 Change-Id: I5b8ad5ca43ee6f519de09ad2a8b1b959637a825b --- .../com/android/dialer/speeddial/SpeedDialFragment.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'java/com/android/dialer/speeddial/SpeedDialFragment.java') diff --git a/java/com/android/dialer/speeddial/SpeedDialFragment.java b/java/com/android/dialer/speeddial/SpeedDialFragment.java index 26893a8d3..b74c06239 100644 --- a/java/com/android/dialer/speeddial/SpeedDialFragment.java +++ b/java/com/android/dialer/speeddial/SpeedDialFragment.java @@ -34,6 +34,7 @@ import android.view.ViewGroup; import android.widget.FrameLayout; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallIntentBuilder; +import com.android.dialer.common.FragmentUtils; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.common.concurrent.SupportUiListener; @@ -132,11 +133,6 @@ public class SpeedDialFragment extends Fragment { return rootLayout; } - public boolean hasFrequents() { - // TODO(calderwoodra) - return false; - } - @Override public void onResume() { super.onResume(); @@ -173,12 +169,17 @@ public class SpeedDialFragment extends Fragment { } private void onSpeedDialUiItemListLoaded(ImmutableList speedDialUiItems) { + LogUtil.enterBlock("SpeedDialFragment.onSpeedDialUiItemListLoaded"); // TODO(calderwoodra): Use DiffUtil to properly update and animate the change adapter.setSpeedDialUiItems( UiItemLoaderComponent.get(getContext()) .speedDialUiItemLoader() .insertDuoChannels(getContext(), speedDialUiItems)); adapter.notifyDataSetChanged(); + if (getActivity() != null) { + FragmentUtils.getParentUnsafe(this, HostInterface.class) + .setHasFrequents(adapter.hasFrequents()); + } } @Override @@ -359,4 +360,10 @@ public class SpeedDialFragment extends Fragment { Contacts.CONTENT_URI, String.valueOf(speedDialUiItem.contactId())))); } } + + /** Interface for {@link SpeedDialFragment} to communicate with its host/parent. */ + public interface HostInterface { + + void setHasFrequents(boolean hasFrequents); + } } -- cgit v1.2.3