admin
2021-05-28 5965c01b38a2e83cecd7616daa11185fc2499303
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.tejia.lijin.app.ui.mine;
 
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
 
import com.bumptech.glide.Glide;
import com.tejia.lijin.app.R;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * Created by weikou2015 on 2018/9/27.
 */
 
public class ShareImageAdapter extends BaseAdapter {
 
    private List<String> mList;
    public List<String> selects = new ArrayList<>();
    private Context mContext;
 
    public ShareImageAdapter(Context context, List<String> list) {
        this.mContext = context;
        this.mList = list;
    }
 
    @Override
    public int getCount() {
        return mList == null ? 0 : mList.size();
    }
 
    @Override
    public Object getItem(int i) {
        return mList.get(i);
    }
 
    @Override
    public long getItemId(int i) {
        return i;
    }
 
    @Override
    public View getView(final int position, View view, ViewGroup viewGroup) {
        view = LayoutInflater.from(mContext).inflate(R.layout.item_image_share, null);
        ImageView iv = view.findViewById(R.id.iv_gooods_more);
        CheckBox cb_edit = view.findViewById(R.id.cb_edit);
 
        Glide.with(mContext).load(mList.get(position)).placeholder(R.drawable.ic_goods_default)
                .error(R.drawable.ic_goods_default).into(iv);
        cb_edit.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    if (!selects.contains(mList.get(position)))
                        selects.add(mList.get(position));
//                    mCBFlag.put(position, true);
                } else {
                    if (selects.contains(mList.get(position)))
                        selects.remove(mList.get(position));
//                    mCBFlag.put(position, false);
                }
            }
        });
        return view;
    }
 
}