diff --git a/.idea/misc.xml b/.idea/misc.xml
index 3c2043d..c1b4dde 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -13,7 +13,7 @@
-
+
diff --git a/library/build.gradle b/library/build.gradle
index b45ddfb..c10e553 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,17 +1,22 @@
apply plugin: 'com.android.library'
-def versionMajor = 0
-def versionMinor = 0
-def versionPatch = 2
-def androidVersionCode = 2
+final def versionMajor = 0
+final def versionMinor = 0
+final def versionPatch = 2
+final def androidVersionCode = 2
-def targetSdk = rootProject.targetSdkVersion;
-def minSdkRed = rootProject.minSdkVersion;
+final def targetSdk = rootProject.targetSdkVersion;
+final def minSdkRed = rootProject.minSdkVersion;
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_7
+ targetCompatibility JavaVersion.VERSION_1_7
+ }
+
defaultConfig {
minSdkVersion minSdkRed
targetSdkVersion targetSdk
diff --git a/library/src/main/java/uk/co/alt236/bluetoothlelib/device/BluetoothLeDevice.java b/library/src/main/java/uk/co/alt236/bluetoothlelib/device/BluetoothLeDevice.java
index f5df8d8..cea2829 100644
--- a/library/src/main/java/uk/co/alt236/bluetoothlelib/device/BluetoothLeDevice.java
+++ b/library/src/main/java/uk/co/alt236/bluetoothlelib/device/BluetoothLeDevice.java
@@ -7,7 +7,6 @@ import android.os.Parcelable;
import java.io.Serializable;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.Map;
import uk.co.alt236.bluetoothlelib.device.adrecord.AdRecordStore;
@@ -71,7 +70,7 @@ public class BluetoothLeDevice implements Parcelable {
mFirstTimestamp = timestamp;
mRecordStore = new AdRecordStore(AdRecordUtils.parseScanRecordAsSparseArray(scanRecord));
mScanRecord = scanRecord;
- mRssiLog = new LimitedLinkHashMap(MAX_RSSI_LOG_SIZE);
+ mRssiLog = new LimitedLinkHashMap<>(MAX_RSSI_LOG_SIZE);
updateRssiReading(timestamp, rssi);
}
@@ -279,17 +278,12 @@ public class BluetoothLeDevice implements Parcelable {
int count = 0;
synchronized (mRssiLog) {
- final Iterator it1 = mRssiLog.keySet().iterator();
- while (it1.hasNext()) {
+ for (final Long aLong : mRssiLog.keySet()) {
count++;
- sum += mRssiLog.get(it1.next());
+ sum += mRssiLog.get(aLong);
}
}
- // for(final Map.Entry e : mRssiLog.entrySet()){
- // count ++;
- // sum += e.getValue();
- // }
if (count > 0) {
return sum / count;
diff --git a/library/src/main/java/uk/co/alt236/bluetoothlelib/device/adrecord/AdRecordStore.java b/library/src/main/java/uk/co/alt236/bluetoothlelib/device/adrecord/AdRecordStore.java
index 39aff91..a0993bd 100644
--- a/library/src/main/java/uk/co/alt236/bluetoothlelib/device/adrecord/AdRecordStore.java
+++ b/library/src/main/java/uk/co/alt236/bluetoothlelib/device/adrecord/AdRecordStore.java
@@ -148,7 +148,7 @@ public class AdRecordStore implements Parcelable {
public static Collection asList(final SparseArray sparseArray) {
if (sparseArray == null) return null;
- final Collection arrayList = new ArrayList(sparseArray.size());
+ final Collection arrayList = new ArrayList<>(sparseArray.size());
for (int i = 0; i < sparseArray.size(); i++) {
arrayList.add(sparseArray.valueAt(i));
}
diff --git a/library/src/main/java/uk/co/alt236/bluetoothlelib/resolvers/CompanyIdentifierResolver.java b/library/src/main/java/uk/co/alt236/bluetoothlelib/resolvers/CompanyIdentifierResolver.java
index aecd4f6..2a7271f 100644
--- a/library/src/main/java/uk/co/alt236/bluetoothlelib/resolvers/CompanyIdentifierResolver.java
+++ b/library/src/main/java/uk/co/alt236/bluetoothlelib/resolvers/CompanyIdentifierResolver.java
@@ -324,7 +324,7 @@ public class CompanyIdentifierResolver {
}
private static SparseArray populateCompanyNameMap() {
- final SparseArray map = new SparseArray();
+ final SparseArray map = new SparseArray<>();
map.put(ERICSSON_TECHNOLOGY_LICENSING, "Ericsson Technology Licensing");
map.put(NOKIA_MOBILE_PHONES, "Nokia Mobile Phones");
diff --git a/library/src/main/java/uk/co/alt236/bluetoothlelib/resolvers/GattAttributeResolver.java b/library/src/main/java/uk/co/alt236/bluetoothlelib/resolvers/GattAttributeResolver.java
index 195a9e6..fc07659 100644
--- a/library/src/main/java/uk/co/alt236/bluetoothlelib/resolvers/GattAttributeResolver.java
+++ b/library/src/main/java/uk/co/alt236/bluetoothlelib/resolvers/GattAttributeResolver.java
@@ -198,7 +198,7 @@ public class GattAttributeResolver {
}
private static Map populateGattAttributesMap() {
- final Map map = new HashMap();
+ final Map map = new HashMap<>();
map.put(BASE_GUID, "Service Discovery Protocol (SDP)");
map.put(SERVICE_DISCOVERY_PROTOCOL_SDP, "User Datagram Protocol (UDP)");
diff --git a/library/src/main/java/uk/co/alt236/bluetoothlelib/util/AdRecordUtils.java b/library/src/main/java/uk/co/alt236/bluetoothlelib/util/AdRecordUtils.java
index 114c2f3..cc87d8a 100644
--- a/library/src/main/java/uk/co/alt236/bluetoothlelib/util/AdRecordUtils.java
+++ b/library/src/main/java/uk/co/alt236/bluetoothlelib/util/AdRecordUtils.java
@@ -50,7 +50,7 @@ public class AdRecordUtils {
* Read out all the AD structures from the raw scan record
*/
public static List parseScanRecordAsList(final byte[] scanRecord) {
- final List records = new ArrayList();
+ final List records = new ArrayList<>();
int index = 0;
while (index < scanRecord.length) {
@@ -76,7 +76,7 @@ public class AdRecordUtils {
@SuppressLint("UseSparseArrays")
public static Map parseScanRecordAsMap(final byte[] scanRecord) {
- final Map records = new HashMap();
+ final Map records = new HashMap<>();
int index = 0;
while (index < scanRecord.length) {
@@ -101,7 +101,7 @@ public class AdRecordUtils {
}
public static SparseArray parseScanRecordAsSparseArray(final byte[] scanRecord) {
- final SparseArray records = new SparseArray();
+ final SparseArray records = new SparseArray<>();
int index = 0;
while (index < scanRecord.length) {
diff --git a/library/src/main/java/uk/co/alt236/bluetoothlelib/util/ByteUtils.java b/library/src/main/java/uk/co/alt236/bluetoothlelib/util/ByteUtils.java
index 2ec67cf..5d4aed0 100644
--- a/library/src/main/java/uk/co/alt236/bluetoothlelib/util/ByteUtils.java
+++ b/library/src/main/java/uk/co/alt236/bluetoothlelib/util/ByteUtils.java
@@ -82,7 +82,7 @@ public class ByteUtils {
* @return the int from byte
*/
public static int getIntFromByte(final byte bite) {
- return Integer.valueOf(bite & 0xFF);
+ return bite & 0xFF;
}
/**
diff --git a/sample_app/build.gradle b/sample_app/build.gradle
index 8f66637..7bcc0e6 100644
--- a/sample_app/build.gradle
+++ b/sample_app/build.gradle
@@ -1,17 +1,22 @@
apply plugin: 'com.android.application'
-def versionMajor = 0
-def versionMinor = 0
-def versionPatch = 3
-def androidVersionCode = 3
+final def versionMajor = 0
+final def versionMinor = 0
+final def versionPatch = 3
+final def androidVersionCode = 3
-def targetSdk = rootProject.targetSdkVersion;
-def minSdkRed = rootProject.minSdkVersion;
+final def targetSdk = rootProject.targetSdkVersion;
+final def minSdkRed = rootProject.minSdkVersion;
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_7
+ targetCompatibility JavaVersion.VERSION_1_7
+ }
+
defaultConfig {
minSdkVersion minSdkRed
targetSdkVersion targetSdk
diff --git a/sample_app/src/main/java/uk/co/alt236/btlescan/activities/DeviceControlActivity.java b/sample_app/src/main/java/uk/co/alt236/btlescan/activities/DeviceControlActivity.java
index f7368bf..a421b88 100644
--- a/sample_app/src/main/java/uk/co/alt236/btlescan/activities/DeviceControlActivity.java
+++ b/sample_app/src/main/java/uk/co/alt236/btlescan/activities/DeviceControlActivity.java
@@ -73,7 +73,7 @@ public class DeviceControlActivity extends Activity {
TextView mDataAsArray;
private BluetoothGattCharacteristic mNotifyCharacteristic;
private BluetoothLeService mBluetoothLeService;
- private List> mGattCharacteristics = new ArrayList>();
+ private List> mGattCharacteristics = new ArrayList<>();
// If a given GATT characteristic is selected, check for supported features. This sample
// demonstrates 'Read' and 'Notify' features. See
// http://d.android.com/reference/android/bluetooth/BluetoothGatt.html for the complete
@@ -177,26 +177,26 @@ public class DeviceControlActivity extends Activity {
String uuid = null;
final String unknownServiceString = getResources().getString(R.string.unknown_service);
final String unknownCharaString = getResources().getString(R.string.unknown_characteristic);
- final List