From 1942986962f3da9440cac9e291e4e39120c62d72 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sat, 21 Nov 2015 21:54:23 +0100 Subject: [PATCH] Removed guava dependency. --- android/build.gradle | 1 - .../ensichat/bluetooth/BluetoothInterface.scala | 13 ++++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 524cc37..c808709 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -16,7 +16,6 @@ dependencies { androidTestCompile 'com.android.support:multidex-instrumentation:1.0.1', { exclude module: 'multidex' } compile 'org.scala-lang:scala-library:2.11.7' - compile 'com.google.guava:guava:18.0' compile 'com.mobsandgeeks:adapter-kit:0.5.3' compile project(path: ':core') } diff --git a/android/src/main/scala/com/nutomic/ensichat/bluetooth/BluetoothInterface.scala b/android/src/main/scala/com/nutomic/ensichat/bluetooth/BluetoothInterface.scala index 67bb71d..f2a83c0 100644 --- a/android/src/main/scala/com/nutomic/ensichat/bluetooth/BluetoothInterface.scala +++ b/android/src/main/scala/com/nutomic/ensichat/bluetooth/BluetoothInterface.scala @@ -7,7 +7,6 @@ import android.content.{BroadcastReceiver, Context, Intent, IntentFilter} import android.os.Handler import android.preference.PreferenceManager import android.util.Log -import com.google.common.collect.HashBiMap import com.nutomic.ensichat.R import com.nutomic.ensichat.core.body.ConnectionInfo import com.nutomic.ensichat.core.interfaces.{Settings, TransmissionInterface} @@ -47,7 +46,7 @@ class BluetoothInterface(context: Context, mainHandler: Handler, private var discovered = Set[Device]() - private val addressDeviceMap = HashBiMap.create[Address, Device.ID]() + private var addressDeviceMap = new HashMap[Address, Device.ID]() /** * Initializes and starts discovery and listening. @@ -174,7 +173,7 @@ class BluetoothInterface(context: Context, mainHandler: Handler, devices -= device.id connections -= device.id connectionHandler.onConnectionClosed() - addressDeviceMap.inverse().remove(device.id) + addressDeviceMap = addressDeviceMap.filterNot(_._2 == device.id) } /** @@ -189,9 +188,9 @@ class BluetoothInterface(context: Context, mainHandler: Handler, case info: ConnectionInfo => val address = crypto.calculateAddress(info.key) // Service.onConnectionOpened sends message, so mapping already needs to be in place. - addressDeviceMap.put(address, device) + addressDeviceMap += (address -> device) if (!connectionHandler.onConnectionOpened(msg)) - addressDeviceMap.remove(address) + addressDeviceMap -= address case _ => connectionHandler.onMessageReceived(msg) } @@ -200,12 +199,12 @@ class BluetoothInterface(context: Context, mainHandler: Handler, * Sends the message to nextHop. */ override def send(nextHop: Address, msg: Message): Unit = - connections.get(addressDeviceMap.get(nextHop)).foreach(_.send(msg)) + connections.get(addressDeviceMap(nextHop)).foreach(_.send(msg)) /** * Returns all active Bluetooth connections. */ def getConnections: Set[Address] = - connections.map(x => addressDeviceMap.inverse().get(x._1)).toSet + connections.map(x => addressDeviceMap.find(_._2 == x._1).get._1).toSet }