Java 7-ness
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -13,7 +13,7 @@
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -73,7 +73,7 @@ public class DeviceControlActivity extends Activity {
|
||||
TextView mDataAsArray;
|
||||
private BluetoothGattCharacteristic mNotifyCharacteristic;
|
||||
private BluetoothLeService mBluetoothLeService;
|
||||
private List<List<BluetoothGattCharacteristic>> mGattCharacteristics = new ArrayList<List<BluetoothGattCharacteristic>>();
|
||||
private List<List<BluetoothGattCharacteristic>> 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<Map<String, String>> gattServiceData = new ArrayList<Map<String, String>>();
|
||||
final List<List<Map<String, String>>> gattCharacteristicData = new ArrayList<List<Map<String, String>>>();
|
||||
mGattCharacteristics = new ArrayList<List<BluetoothGattCharacteristic>>();
|
||||
final List<Map<String, String>> gattServiceData = new ArrayList<>();
|
||||
final List<List<Map<String, String>>> gattCharacteristicData = new ArrayList<>();
|
||||
mGattCharacteristics = new ArrayList<>();
|
||||
|
||||
// Loops through available GATT Services.
|
||||
for (final BluetoothGattService gattService : gattServices) {
|
||||
final Map<String, String> currentServiceData = new HashMap<String, String>();
|
||||
final Map<String, String> currentServiceData = new HashMap<>();
|
||||
uuid = gattService.getUuid().toString();
|
||||
currentServiceData.put(LIST_NAME, GattAttributeResolver.getAttributeName(uuid, unknownServiceString));
|
||||
currentServiceData.put(LIST_UUID, uuid);
|
||||
gattServiceData.add(currentServiceData);
|
||||
|
||||
final List<Map<String, String>> gattCharacteristicGroupData = new ArrayList<Map<String, String>>();
|
||||
final List<Map<String, String>> gattCharacteristicGroupData = new ArrayList<>();
|
||||
final List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics();
|
||||
final List<BluetoothGattCharacteristic> charas = new ArrayList<BluetoothGattCharacteristic>();
|
||||
final List<BluetoothGattCharacteristic> charas = new ArrayList<>();
|
||||
|
||||
// Loops through available Characteristics.
|
||||
for (final BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
|
||||
charas.add(gattCharacteristic);
|
||||
final Map<String, String> currentCharaData = new HashMap<String, String>();
|
||||
final Map<String, String> currentCharaData = new HashMap<>();
|
||||
uuid = gattCharacteristic.getUuid().toString();
|
||||
currentCharaData.put(LIST_NAME, GattAttributeResolver.getAttributeName(uuid, unknownCharaString));
|
||||
currentCharaData.put(LIST_UUID, uuid);
|
||||
|
||||
@@ -29,7 +29,7 @@ public class BluetoothLeDeviceStore {
|
||||
|
||||
|
||||
public BluetoothLeDeviceStore() {
|
||||
mDeviceMap = new HashMap<String, BluetoothLeDevice>();
|
||||
mDeviceMap = new HashMap<>();
|
||||
}
|
||||
|
||||
public void addDevice(final BluetoothLeDevice device) {
|
||||
@@ -45,14 +45,14 @@ public class BluetoothLeDeviceStore {
|
||||
}
|
||||
|
||||
public EasyObjectCursor<BluetoothLeDevice> getDeviceCursor() {
|
||||
return new EasyObjectCursor<BluetoothLeDevice>(
|
||||
return new EasyObjectCursor<>(
|
||||
BluetoothLeDevice.class,
|
||||
getDeviceList(),
|
||||
"address");
|
||||
}
|
||||
|
||||
public List<BluetoothLeDevice> getDeviceList() {
|
||||
final List<BluetoothLeDevice> methodResult = new ArrayList<BluetoothLeDevice>(mDeviceMap.values());
|
||||
final List<BluetoothLeDevice> methodResult = new ArrayList<>(mDeviceMap.values());
|
||||
|
||||
Collections.sort(methodResult, new Comparator<BluetoothLeDevice>() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user