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
This commit is contained in:
@@ -151,13 +151,10 @@ public class DashboardAdapterV2 extends RecyclerView.Adapter<DashboardAdapterV2.
|
||||
if (list.size() == 1) {
|
||||
// The only suggestion is dismissed, and the the empty suggestion container will
|
||||
// remain as the dashboard item. Need to refresh the dashboard list.
|
||||
final DashboardDataV2 prevData = mDashboardData;
|
||||
mDashboardData = new DashboardDataV2.Builder(prevData)
|
||||
.setSuggestions(null)
|
||||
.build();
|
||||
notifyDashboardDataChanged(prevData);
|
||||
setSuggestions(null);
|
||||
} else {
|
||||
mSuggestionAdapter.removeSuggestion(suggestion);
|
||||
notifyItemChanged(0, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -55,6 +55,7 @@ public class SuggestionAdapterV2 extends RecyclerView.Adapter<DashboardItemHolde
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private final IconCache mCache;
|
||||
private final ArrayList<String> 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<DashboardItemHolde
|
||||
mCache = new IconCache(context);
|
||||
final FeatureFactory factory = FeatureFactory.getFactory(context);
|
||||
mMetricsFeatureProvider = factory.getMetricsFeatureProvider();
|
||||
mSuggestionFeatureProvider = factory.getSuggestionFeatureProvider(context);
|
||||
mCallback = callback;
|
||||
if (savedInstanceState != null) {
|
||||
mSuggestions = savedInstanceState.getParcelableArrayList(STATE_SUGGESTION_LIST);
|
||||
@@ -129,13 +131,13 @@ public class SuggestionAdapterV2 extends RecyclerView.Adapter<DashboardItemHolde
|
||||
|
||||
final ImageView closeButton = holder.itemView.findViewById(R.id.close_button);
|
||||
if (closeButton != null) {
|
||||
if (mCallback != null) {
|
||||
closeButton.setOnClickListener(v -> {
|
||||
closeButton.setOnClickListener(v -> {
|
||||
mSuggestionFeatureProvider.dismissSuggestion(
|
||||
mContext, mSuggestionControllerMixin, suggestion);
|
||||
if (mCallback != null) {
|
||||
mCallback.onSuggestionClosed(suggestion);
|
||||
});
|
||||
} else {
|
||||
closeButton.setOnClickListener(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
View clickHandler = holder.itemView;
|
||||
|
@@ -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<Suggestion> suggestions) {
|
||||
|
Reference in New Issue
Block a user