陈奇
2018-11-01 cdbaf79d124d46b69dc62b653fde55f9d40b5534
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
package com.moral.yunfushao.adapter;
 
import android.bluetooth.BluetoothDevice;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;
 
import com.clj.fastble.data.ScanResult;
import com.moral.andbrickslib.baseadapter.recyclerview.CommonAdapter;
import com.moral.andbrickslib.baseadapter.recyclerview.base.ViewHolder;
import com.moral.andbrickslib.utils.StringUtils;
import com.moral.yunfushao.R;
 
import java.util.List;
 
/**
 * Created by haijiang on 2017/7/6.
 */
 
public class BleDeviceAdapter extends CommonAdapter<ScanResult> {
    public BleDeviceAdapter(RecyclerView v, int layoutId, List<ScanResult> datas) {
        super(v, layoutId, datas);
    }
 
    @Override
    protected void convert(ViewHolder holder, ScanResult scanResult, int position) {
        TextView tv_name = holder.getView(R.id.tv_name);
        BluetoothDevice device = scanResult.getDevice();
        if (!StringUtils.isEmpty(device.getName())) {
            tv_name.setText(device.getName() + "\n" + device.getAddress());
        } else {
            tv_name.setText("未知设备" + "\n" + device.getAddress());
        }
    }
}