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;
|
}
|
}
|