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;