当我单击心形图标时,它会将项目发送到收藏夹并更改颜色,但是当加载活动时,图标会恢复正常颜色,但该项目仍在收藏夹中。
我如何检查收藏夹中的项目是否基于数据库房间的监听器之类的东西更改图标颜色?
这是适配器:-
public class BSAdapter extends RecyclerView.Adapter<BSAdapter.BestSellerHolder> {
private Context context;
private List<ProductsBestSeller> bestSellerList;
public BSAdapter(Context context, List<ProductsBestSeller> bestSellerList) {
this.context = context;
this.bestSellerList = bestSellerList;
}
@Override
public BestSellerHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View bestSellerView = LayoutInflater.from(parent.getContext()).inflate(R.layout.default_product_items_horizontal, parent, false);
return new BestSellerHolder(bestSellerView);
}
@Override
public void onBindViewHolder(BestSellerHolder holder, int position) {
ProductsBestSeller bestSeller = bestSellerList.get(position);
holder.onBindData(bestSeller);
}
@Override
public int getItemCount() {
if (bestSellerList != null) {
return bestSellerList.size();
} else {
return 0;
}
}
public class BestSellerHolder extends RecyclerView.ViewHolder {
TextView productName, productPrice;
ImageView productIcon;
CheckBox favouriteIcon;
public BestSellerHolder(View itemView) {
super(itemView);
productIcon = itemView.findViewById(R.id.product_icon_horizontal);
productName = itemView.findViewById(R.id.product_name_horizontal);
productPrice = itemView.findViewById(R.id.product_price_horizontal);
favouriteIcon = itemView.findViewById(R.id.favourite_icon_horizontal);
}
森栏
相关分类