From b05ab47822a0d6f77c4c68438241053c0f8d0712 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Mon, 8 Aug 2022 10:38:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8E=86=E5=8F=B2=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=EF=BC=8C=E6=90=9C=E7=B4=A2=E4=BC=98=E5=8C=96=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/main/adapter/SearchRecommendAdapter.java | 7 +++++++ .../main/views/SearchRecommendHeardViewHolder.java | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/main/src/main/java/com/yunbao/main/adapter/SearchRecommendAdapter.java b/main/src/main/java/com/yunbao/main/adapter/SearchRecommendAdapter.java index d6b162c4c..a63ced971 100644 --- a/main/src/main/java/com/yunbao/main/adapter/SearchRecommendAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/SearchRecommendAdapter.java @@ -53,6 +53,13 @@ public class SearchRecommendAdapter extends RecyclerView.Adapter { public void onChipClick(String chip) { Bus.get().post(chip); } + + @Override + public void searchDel() { + //删除历史记录 + recommendModels.remove(position); + notifyDataSetChanged(); + } }); } else { SearchRecommendBodyViewHolder bodyViewHolder = (SearchRecommendBodyViewHolder) holder; diff --git a/main/src/main/java/com/yunbao/main/views/SearchRecommendHeardViewHolder.java b/main/src/main/java/com/yunbao/main/views/SearchRecommendHeardViewHolder.java index 0fa606dfa..3a1c21114 100644 --- a/main/src/main/java/com/yunbao/main/views/SearchRecommendHeardViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/SearchRecommendHeardViewHolder.java @@ -11,6 +11,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import com.yunbao.common.manager.SearchHistoryRecordManager; import com.yunbao.main.R; import java.util.Map; @@ -58,6 +59,15 @@ public class SearchRecommendHeardViewHolder extends RecyclerView.ViewHolder { } }); } + searchDel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (callBack != null) { + SearchHistoryRecordManager.get(itemView.getContext()).removeAllHistoryRecord(); + callBack.searchDel(); + } + } + }); } /** @@ -65,6 +75,8 @@ public class SearchRecommendHeardViewHolder extends RecyclerView.ViewHolder { */ public interface SearchRecommendHeardCallBack { void onChipClick(String chip); + + void searchDel(); } private SearchRecommendHeardCallBack callBack;