hc
2023-02-13 e440ec23c5a540cdd3f7464e8779219be6fd3d95
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
78
79
package com.rockchip.alexa.jacky.adapter;
 
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
 
import com.rockchip.alexa.jacky.R;
import com.rockchip.alexa.jacky.info.BluInfo;
 
import java.util.List;
 
/**
 * Created by Administrator on 2017/3/14.
 */
 
public class BluListAdapter extends BaseAdapter {
    private LayoutInflater inflater;
    private List<BluInfo> list;
 
    public BluListAdapter(Context context, List<BluInfo> list){
        this.inflater=LayoutInflater.from(context);
        this.list=list;
    }
 
    public List<BluInfo> getList() {
        return list;
    }
 
    public void setList(List<BluInfo> scanResult) {
        this.list = scanResult;
    }
 
    @Override
    public int getCount() {
        return list.size();
    }
 
    @Override
    public Object getItem(int position) {
        return position;
    }
 
    @Override
    public long getItemId(int position) {
        return position;
    }
 
    @SuppressLint({ "ViewHolder", "InflateParams" })
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (list.get(position).getTag() != null && !list.get(position).getTag().isEmpty()) {
            View view = inflater.inflate(R.layout.blu_listitem_tag, null);
 
            BluInfo blu = list.get(position);
            TextView name = (TextView) view.findViewById(R.id.name);
 
            Log.d("Test", "blu.getTag() i:" + position + "; " + blu.getTag());
            name.setText(blu.getTag());
            return view;
        } else {
            View view = inflater.inflate(R.layout.blu_listitem, null);
 
            BluInfo blu = list.get(position);
            TextView name = (TextView) view.findViewById(R.id.name);
            TextView addr = (TextView) view.findViewById(R.id.addr);
 
            name.setText(blu.getName());
            addr.setText(blu.getAddr());
 
            return view;
        }
    }
}