Look at the renderings first

2. The screenshot is an item of Recyclerview1, and the one in red box is Recyclerview2. Obviously, the picture is an item of Recyclerview2

Madapter.sethasstableids (true);) + (override adpater’s getItemId to ensure itemId uniqueness) + Call notifyDataSetChanged()

Also: Give imageView.settag ()

(In fact, it can be solved, if not, there must be a problem with their own code, such as my example)

None of these methods work for me, and every time I enter a breakpoint getTag is null, I get bored. Later, the code in Adpter1 was modified: in the onBindViewHolder method, determine whether the onBindViewHolder adaptation is null, null and new

 if (helper.itemOrder_GoodInfor.getAdapter() == null) {
    OrderListGoodsAdapter1 adapter = new OrderListGoodsAdapter1(mContext);
    adapter.setHasStableIds(true);
    GridLayoutManager managerBtn = new GridLayoutManager(mContext, 1);
    helper.itemOrder_GoodInfor.setLayoutManager(managerBtn);
    ((SimpleItemAnimator) helper.itemOrder_GoodInfor.getItemAnimator()).setSupportsChangeAnimations(false); helper.itemOrder_GoodInfor.getItemAnimator().setChangeDuration(0); Helper.itemorder_goodinfor.settag (R.I.D.I temOrder_GoodInfor, item.getid ()); helper.itemOrder_GoodInfor.setAdapter(adapter); helper.itemOrder_GoodInfor.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent event) {
            return   helper.itemView.onTouchEvent(event);
        }
    });

//            helper.itemOrder_GoodInfor.setOnItemClickListener(new ByRecyclerView.OnItemClickListener() //{
//                @Override
//                public void onClick(View v, int position) {
//                    Object tag = helper.itemOrder_GoodInfor.getTag(R.id.itemOrder_GoodInfor);
//                    MyOrderDetailActivity.start(mContext, (int) tag);
//                }
//            });

//            adapter.setNewData(item.getGoods());
        adapter.updateData(item.getGoods());
    } else {
        ((OrderListGoodsAdapter1) helper.itemOrder_GoodInfor.getAdapter()).updateData(item.getGoods());
    }
Copy the code

Adapter2 and I have OrderListGoodsAdapter1 part of the code is as follows: Set setTag to Imageview orderCenter_iv

public void updateData(List<OrderGroup.GoodsBean> dataSet) { this.listData = dataSet; notifyDataSetChanged(); } private void onBindMainViewHolder(ViewHolder binding, int position) { OrderGroup.GoodsBean item = listData.get(position); /** * Solve the sliding recyclerView cause glide image loading flicker * 1. usingset2.Glide Set skipMemoryCache(true*/ String tag = (String)binding.orderCenter_iv.getTag(R.i.D.ordercenter_iv); String image = item.getImage();if(item.getSpec_image() ! = null && !"".equals(item.getSpec_image())){
            image = item.getSpec_image();
        }
        if(! ImageUrl (articleViewholder.iv, bean.getimage (), height, height); // imageUrl(articleViewholder.iv, bean.getimage (), height, height); Glide.with(mContext).load(image) .transform(new CropSquareTransformation()) .dontAnimate() .skipMemoryCache(false)
//                    .apply(options)
                    .into(binding.orderCenter_iv);
            binding.orderCenter_iv.setTag(R.id.orderCenter_iv,image);
        }

        String tag1 = (String)binding.orderCenter_iv.getTag(R.id.orderCenter_iv);
        binding.orderCenter_goodName.setText(TextViewUtils.noEmpty(item.getGoods_name()));
        binding.tv_model.setText(TextViewUtils.noEmpty(item.getGoods_attr()));
        binding.tv_price.setText(TextViewUtils.noEmpty(item.getGoods_price()));
        binding.tv_count.setText("x" + +item.getTotal_num());
    }
Copy the code

Then the list refresh picture will not flash, but click the item to enter the item details, found that the data is wrong !!!!

It turned out that I was using setOnItemClickListener in RecyclerView2, so the commodity ID obtained was wrong. Then I changed it to setOnItemClickListener in RecyclerView1. Recyclerview2 does not respond when you click on a nested list. It turned out that recyclerView nested recyclerView caused by the conflict. The final solution: RecyclerView2 set setOnTouchListener to listen, give focus to recyclerview1 item processing

            helper.itemOrder_GoodInfor.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View view, MotionEvent event) {
                    returnhelper.itemView.onTouchEvent(event); }});Copy the code

Then set up click listening for item in Adapter1

        helper.itemView.setOnClickListener(view -> {
            MyOrderDetailActivity.start(mContext, item.getId());
        });

Copy the code

All right, perfect! Note: this interface does not do pagination because the backend is lazy, so if pagination causes other problems, you need to deal with it yourself.