endian11
2021-02-03 225473d256d26d4d8f9469038d02d28ac1c866be
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
74
75
76
77
package safeluck.drive.evaluation.adapter;
 
import android.net.wifi.ScanResult;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
 
 
 
import java.util.List;
import java.util.zip.Inflater;
 
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.app;
import safeluck.drive.evaluation.bean.AYBluetoothDevice;
 
/**
 * Created by hanguojing on 2016/12/25 12:17
 * 用于显示wifi列表
 */
 
public class AdapterBleList extends BaseAdapter {
    private List<AYBluetoothDevice> mList;
    public AdapterBleList(List<AYBluetoothDevice> list){
        mList = list;
    }
    public void setList(List<AYBluetoothDevice> list){
        mList = list;
        notifyDataSetChanged();
    }
    @Override
    public int getCount() {
        return mList ==  null ? 0 : mList.size();
    }
 
    @Override
    public AYBluetoothDevice getItem(int position) {
        if(mList != null && mList.size() > position){
            return mList.get(position);
        }else{
        return null;}
    }
 
    @Override
    public long getItemId(int position) {
        return  mList != null && mList.size() > position ? position : 0;
    }
 
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null){
            convertView = LayoutInflater.from(app.getAppContext()).inflate(R.layout.item_wifi_list_auto,parent,false);
 
            holder = new ViewHolder();
            holder.mTvShow = (TextView) convertView.findViewById(R.id.tv_auto_wifi);
            holder.mTvShow_mac = (TextView) convertView.findViewById(R.id.tv_auto_mac);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        String name = getItem(position).getBleDevice().getName();
        if (TextUtils.isEmpty(name)){
            name = "未知";
        }
        holder.mTvShow.setText(name);
        holder.mTvShow_mac.setText(getItem(position).getBleDevice().getAddress());
        return convertView;
    }
    class ViewHolder{
        public TextView mTvShow;
        public TextView mTvShow_mac;
    }
}