Android Open Source - BikeStation Device Adapter

From Project

Back to project page BikeStation.


The source code is released under:

GNU General Public License

If you think the Android project BikeStation listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*from w  w  w .j a v a  2s  .com*/
import android.bluetooth.BluetoothDevice;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import java.util.ArrayList;
import java.util.List;

public class DeviceAdapter extends BaseAdapter {

    private List<BluetoothDevice> devices;
    private final Activity context;

    public DeviceAdapter(Activity context) {
        this.context = context;
        this.devices = new ArrayList<BluetoothDevice>();

    public int getCount() {
        return devices.size();

    public Object getItem(int i) {
        return devices.get(i);

    public long getItemId(int i) {
        return i;

    public View getView(int i, View view, ViewGroup viewGroup) {
        View rowView = view;
        if (rowView == null) {
            LayoutInflater inflater = context.getLayoutInflater();
            rowView = inflater.inflate(R.layout.item_device, null, true);

        TextView tvAccountName = (TextView)rowView.findViewById(;

//        if (i==2) {
//            ProgressBar prgbarLock = (ProgressBar) rowView.findViewById(;
//            prgbarLock.setVisibility(View.VISIBLE);
//        }
        return rowView;

    public void addDevice(BluetoothDevice device){
        for (BluetoothDevice d : devices){
            if (d.getAddress().equals(device.getAddress())
                    && d.getName().equals(device.getName()))

Java Source Code List