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) {