Android Open Source - Bluetooth-Manager-for-Glass Ble Device Card Scroll Adapter






From Project

Back to project page Bluetooth-Manager-for-Glass.

License

The source code is released under:

MIT License

If you think the Android project Bluetooth-Manager-for-Glass 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.recursivepenguin.bluetoothmanagerforglass.ble;
// w  w w.jav a2 s  . c  o m
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.android.glass.widget.CardScrollAdapter;
import com.recursivepenguin.bluetoothmanagerforglass.R;

import java.util.List;

public class BleDeviceCardScrollAdapter extends CardScrollAdapter {
    List<BleDevice> mBleDevices;

    Context context;

    public BleDeviceCardScrollAdapter(Context context, List<BleDevice> devices) {
        mBleDevices = devices;
        this.context = context;
    }

    public void addDevice(BleDevice device) {
        mBleDevices.add(device);
    }

    @Override
    public int getPosition(Object item) {
        return mBleDevices.indexOf(item);
    }

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

    @Override
    public BleDevice getItem(int position) {
        return mBleDevices.get(position);
    }

    class ViewHolder {
        ImageView icon;
        TextView name;
        TextView address;
        TextView rssi;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.ble_card, null);
            holder = new ViewHolder();

            holder.icon = (ImageView) convertView.findViewById(R.id.imageView);
            holder.name = (TextView) convertView.findViewById(R.id.name);
            holder.address = (TextView) convertView.findViewById(R.id.address);
            holder.rssi = (TextView) convertView.findViewById(R.id.rssi);
            convertView.setTag(holder);
        }
        else {
            holder = (ViewHolder) convertView.getTag();
        }

        BleDevice device = getItem(position);
        holder.name.setText(device.getName());
        holder.address.setText(device.getAddress());
        holder.rssi.setText(context.getString(R.string.rssi_value, device.getRssi()));

        return convertView;
    }
}




Java Source Code List

com.movisens.smartgattlib.Characteristic.java
com.movisens.smartgattlib.Descriptor.java
com.movisens.smartgattlib.GattUtils.java
com.movisens.smartgattlib.Service.java
com.recursivepenguin.bluetoothmanagerforglass.BluetoothDeviceCardScrollAdapter.java
com.recursivepenguin.bluetoothmanagerforglass.MainActivity.java
com.recursivepenguin.bluetoothmanagerforglass.PairDevicesActivity.java
com.recursivepenguin.bluetoothmanagerforglass.PairedDevicesListActivity.java
com.recursivepenguin.bluetoothmanagerforglass.ble.BleCharacteristicCardScrollAdapter.java
com.recursivepenguin.bluetoothmanagerforglass.ble.BleDeviceCardScrollAdapter.java
com.recursivepenguin.bluetoothmanagerforglass.ble.BleDevice.java
com.recursivepenguin.bluetoothmanagerforglass.ble.BleDevicesActivity.java
com.recursivepenguin.bluetoothmanagerforglass.ble.BleServiceCardScrollAdapter.java
com.recursivepenguin.bluetoothmanagerforglass.ble.BleServicesActivity.java