Android Open Source - BikeStation Device Adapter






From Project

Back to project page BikeStation.

License

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

package com.bikestation.app.adapter;
/*from w  w  w .j a v a  2s  .com*/
import android.app.Activity;
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 com.kdravolin.smartlock.app.R;

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

    @Override
    public int getCount() {
        return devices.size();
    }

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

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    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(R.id.tv_device_name);
        tvAccountName.setText(devices.get(i).getName());

//        if (i==2) {
//            ProgressBar prgbarLock = (ProgressBar) rowView.findViewById(R.id.prgbar_device_load);
//            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()))
                return;
        }
        devices.add(device);
        notifyDataSetChanged();
    }
}




Java Source Code List

com.bikestation.app.BluetoothConnector.java
com.bikestation.app.BluetoothWorker.java
com.bikestation.app.ExtApp.java
com.bikestation.app.History.java
com.bikestation.app.Lock.java
com.bikestation.app.User.java
com.bikestation.app.account.AccountAuthenticator.java
com.bikestation.app.account.AuthenticationService.java
com.bikestation.app.activity.AccountActivity.java
com.bikestation.app.activity.BikesActivity.java
com.bikestation.app.activity.DeviceActivity.java
com.bikestation.app.activity.TimeActivity.java
com.bikestation.app.adapter.BikesAdapter.java
com.bikestation.app.adapter.DeviceAdapter.java