Java 7-ness
This commit is contained in:
+11
-6
@@ -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
|
||||
|
||||
@@ -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<Long, Integer>(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<Long> 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<Long,Integer> e : mRssiLog.entrySet()){
|
||||
// count ++;
|
||||
// sum += e.getValue();
|
||||
// }
|
||||
|
||||
if (count > 0) {
|
||||
return sum / count;
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ public class AdRecordStore implements Parcelable {
|
||||
public static <C> Collection<C> asList(final SparseArray<C> sparseArray) {
|
||||
if (sparseArray == null) return null;
|
||||
|
||||
final Collection<C> arrayList = new ArrayList<C>(sparseArray.size());
|
||||
final Collection<C> arrayList = new ArrayList<>(sparseArray.size());
|
||||
for (int i = 0; i < sparseArray.size(); i++) {
|
||||
arrayList.add(sparseArray.valueAt(i));
|
||||
}
|
||||
|
||||
+1
-1
@@ -324,7 +324,7 @@ public class CompanyIdentifierResolver {
|
||||
}
|
||||
|
||||
private static SparseArray<String> populateCompanyNameMap() {
|
||||
final SparseArray<String> map = new SparseArray<String>();
|
||||
final SparseArray<String> map = new SparseArray<>();
|
||||
|
||||
map.put(ERICSSON_TECHNOLOGY_LICENSING, "Ericsson Technology Licensing");
|
||||
map.put(NOKIA_MOBILE_PHONES, "Nokia Mobile Phones");
|
||||
|
||||
+1
-1
@@ -198,7 +198,7 @@ public class GattAttributeResolver {
|
||||
}
|
||||
|
||||
private static Map<String, String> populateGattAttributesMap() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
|
||||
map.put(BASE_GUID, "Service Discovery Protocol (SDP)");
|
||||
map.put(SERVICE_DISCOVERY_PROTOCOL_SDP, "User Datagram Protocol (UDP)");
|
||||
|
||||
@@ -50,7 +50,7 @@ public class AdRecordUtils {
|
||||
* Read out all the AD structures from the raw scan record
|
||||
*/
|
||||
public static List<AdRecord> parseScanRecordAsList(final byte[] scanRecord) {
|
||||
final List<AdRecord> records = new ArrayList<AdRecord>();
|
||||
final List<AdRecord> records = new ArrayList<>();
|
||||
|
||||
int index = 0;
|
||||
while (index < scanRecord.length) {
|
||||
@@ -76,7 +76,7 @@ public class AdRecordUtils {
|
||||
|
||||
@SuppressLint("UseSparseArrays")
|
||||
public static Map<Integer, AdRecord> parseScanRecordAsMap(final byte[] scanRecord) {
|
||||
final Map<Integer, AdRecord> records = new HashMap<Integer, AdRecord>();
|
||||
final Map<Integer, AdRecord> records = new HashMap<>();
|
||||
|
||||
int index = 0;
|
||||
while (index < scanRecord.length) {
|
||||
@@ -101,7 +101,7 @@ public class AdRecordUtils {
|
||||
}
|
||||
|
||||
public static SparseArray<AdRecord> parseScanRecordAsSparseArray(final byte[] scanRecord) {
|
||||
final SparseArray<AdRecord> records = new SparseArray<AdRecord>();
|
||||
final SparseArray<AdRecord> records = new SparseArray<>();
|
||||
|
||||
int index = 0;
|
||||
while (index < scanRecord.length) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user