删除历史记录,搜索优化完成

This commit is contained in:
18401019693 2022-08-08 10:38:47 +08:00
parent 04b720311c
commit b05ab47822
2 changed files with 19 additions and 0 deletions

View File

@ -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;

View File

@ -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;