Android Open Source - lamp Bluetooth Device Wrapper






From Project

Back to project page lamp.

License

The source code is released under:

GNU General Public License

If you think the Android project lamp 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 cz.tomsuch.lampicka.util;
//w  w  w.  j a  v  a  2  s.  co  m
import android.bluetooth.BluetoothDevice;
import android.os.ParcelUuid;
import android.os.Parcelable;

/**
 * Wrapper around BluetoothDevice, to wrap persisting the class, which could not
 * be manually instantiated
 * */
public class BluetoothDeviceWrapper {

  private String address = null;
  private String name = null;
  private ParcelUuid uuids[] = null;

  /**
   * Default constructor, from correctly obtained BluetoothAdapter
   * 
   * @param device
   *            BluetoothDevice from BluetoothAdapter
   * */
  public BluetoothDeviceWrapper(BluetoothDevice device) {
    this(device.getAddress(), device.getName(), device.getUuids());
  }

  /**
   * Helper constructor used by {@link Preferences} to restore device from
   * shared preferences
   * 
   * @param address
   *            mac address of persisted device
   * @param name
   *            name of persisted device
   * @param uuids
   *            service uuids of persisted device
   * */
  public BluetoothDeviceWrapper(String address, String name,
      ParcelUuid[] uuids) {
    this.setAddress(address);
    this.setName(name);
    this.setUuids(uuids);
  }

  /**
   * Constructor working with
   * 
   * @param parcelableExtra
   *            if device is obtained via
   *            Activity.getIntent().getParcelableExtra(String key)
   * */
  public BluetoothDeviceWrapper(Parcelable parcelableExtra) {
    this((BluetoothDevice) parcelableExtra);
  }

  /**
   * Wrapper around device service uuids
   * */
  public ParcelUuid[] getUuids() {
    return uuids;
  }

  /**
   * Wrapper setter of device service uuids
   * 
   * @param uuids
   *            device service uuids
   * */
  public void setUuids(ParcelUuid uuids[]) {
    this.uuids = uuids;
  }

  /**
   * Wrapper around device name
   * */
  public String getName() {
    return name;
  }

  /**
   * Setter for device name
   * 
   * @param name
   *            Device name
   * */
  public void setName(String name) {
    this.name = name;
  }

  /**
   * Wrapper for device mac address
   * */
  public String getAddress() {
    return address;
  }

  /**
   * Setter for device mac address
   * */
  public void setAddress(String address) {
    this.address = address;
  }

  /**
   * Validates if device is usable, after persist-restore cycle
   * */
  public boolean isValid() {
    return this.address != null;
  }

}




Java Source Code List

cz.tomsuch.lampicka.AppController.java
cz.tomsuch.lampicka.abstracts.CustomSeekBar.java
cz.tomsuch.lampicka.activities.LampActivity.java
cz.tomsuch.lampicka.activities.LampsActivity.java
cz.tomsuch.lampicka.adapters.BluetoothDevicesAdapter.java
cz.tomsuch.lampicka.enums.BluetoothLampBacklightMode.java
cz.tomsuch.lampicka.enums.BluetoothLampColorSetMode.java
cz.tomsuch.lampicka.enums.BluetoothLampCommand.java
cz.tomsuch.lampicka.enums.BluetoothLampEffect.java
cz.tomsuch.lampicka.impl.DefaultBluetoothLamp.java
cz.tomsuch.lampicka.interfaces.BluetoothInputLineListener.java
cz.tomsuch.lampicka.interfaces.BluetoothLampCommandListener.java
cz.tomsuch.lampicka.interfaces.BluetoothLamp.java
cz.tomsuch.lampicka.interfaces.OnColorChangedListener.java
cz.tomsuch.lampicka.interfaces.PalleteDialogColorListener.java
cz.tomsuch.lampicka.pallete.ColorChooserDialog.java
cz.tomsuch.lampicka.pallete.PalleteDialog.java
cz.tomsuch.lampicka.util.BluetoothDeviceComparator.java
cz.tomsuch.lampicka.util.BluetoothDeviceWrapper.java
cz.tomsuch.lampicka.util.BluetoothSocketListener.java
cz.tomsuch.lampicka.util.ColorPickerView.java
cz.tomsuch.lampicka.util.FixedBluetoothSocket.java
cz.tomsuch.lampicka.util.HorizontalSeekBar.java
cz.tomsuch.lampicka.util.Preferences.java
cz.tomsuch.lampicka.util.VerticalSeekBar.java