From 0e3225211195c95b17d626f61aa014fc1d40c9ed Mon Sep 17 00:00:00 2001 From: Doris Ling Date: Tue, 23 Jan 2018 12:08:50 -0800 Subject: [PATCH] Dismiss suggestion when close button is clicked. - add handling to the suggestion card to dismiss the suggestion when the close button is clicked. Bug: 70573674 Test: make RunSettingsRoboTests Change-Id: I8155efc326242abde753a633009e2579a9b3aa9b --- .../settings/dashboard/DashboardAdapterV2.java | 7 ++----- .../dashboard/suggestions/SuggestionAdapterV2.java | 14 ++++++++------ .../suggestions/SuggestionAdapterV2Test.java | 5 ++++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/com/android/settings/dashboard/DashboardAdapterV2.java b/src/com/android/settings/dashboard/DashboardAdapterV2.java index 7cd4f38e442..f98b440eff8 100644 --- a/src/com/android/settings/dashboard/DashboardAdapterV2.java +++ b/src/com/android/settings/dashboard/DashboardAdapterV2.java @@ -151,13 +151,10 @@ public class DashboardAdapterV2 extends RecyclerView.Adapter mSuggestionsShownLogged; + private final SuggestionFeatureProvider mSuggestionFeatureProvider; private final SuggestionControllerMixin mSuggestionControllerMixin; private final Callback mCallback; private final CardConfig mConfig; @@ -75,6 +76,7 @@ public class SuggestionAdapterV2 extends RecyclerView.Adapter { + closeButton.setOnClickListener(v -> { + mSuggestionFeatureProvider.dismissSuggestion( + mContext, mSuggestionControllerMixin, suggestion); + if (mCallback != null) { mCallback.onSuggestionClosed(suggestion); - }); - } else { - closeButton.setOnClickListener(null); - } + } + }); } View clickHandler = holder.itemView; diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2Test.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2Test.java index 1e76e2db6a4..dd9d0e499d5 100644 --- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2Test.java +++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2Test.java @@ -200,7 +200,10 @@ public class SuggestionAdapterV2Test { mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0); mSuggestionHolder.itemView.findViewById(R.id.close_button).performClick(); - verify(callback).onSuggestionClosed(suggestions.get(0)); + final Suggestion suggestion = suggestions.get(0); + verify(mFeatureFactory.suggestionsFeatureProvider).dismissSuggestion( + mActivity, mSuggestionControllerMixin, suggestion); + verify(callback).onSuggestionClosed(suggestion); } private void setupSuggestions(Context context, List suggestions) {