mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-21 16:34:23 +01:00
feature: Add new CSC Screen
This commit is contained in:
7
lib_broadcast/build.gradle
Normal file
7
lib_broadcast/build.gradle
Normal file
@@ -0,0 +1,7 @@
|
||||
apply from: rootProject.file("library.gradle")
|
||||
|
||||
dependencies {
|
||||
implementation project(":lib_events")
|
||||
|
||||
implementation libs.kotlin.coroutines
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package no.nordicsemi.android.broadcast
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("no.nordicsemi.android.broadcast.test", appContext.packageName)
|
||||
}
|
||||
}
|
||||
4
lib_broadcast/src/main/AndroidManifest.xml
Normal file
4
lib_broadcast/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest package="no.nordicsemi.android.broadcast">
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,34 @@
|
||||
package no.nordicsemi.android.broadcast
|
||||
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.SharedFlow
|
||||
import no.nordicsemi.android.events.BluetoothReadDataEvent
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class BluetoothDataReadBroadcast @Inject constructor() {
|
||||
|
||||
private val _event = MutableSharedFlow<BluetoothReadDataEvent>(
|
||||
replay = 1,
|
||||
extraBufferCapacity = 1,
|
||||
onBufferOverflow = BufferOverflow.DROP_OLDEST
|
||||
)
|
||||
val events: SharedFlow<BluetoothReadDataEvent> = _event
|
||||
|
||||
private val _wheelSize = MutableSharedFlow<Int>(
|
||||
replay = 1,
|
||||
extraBufferCapacity = 1,
|
||||
onBufferOverflow = BufferOverflow.DROP_OLDEST
|
||||
)
|
||||
val wheelSize: SharedFlow<Int> = _wheelSize
|
||||
|
||||
fun offer(newEvent: BluetoothReadDataEvent) {
|
||||
_event.tryEmit(newEvent)
|
||||
}
|
||||
|
||||
fun setWheelSize(size: Int) {
|
||||
_wheelSize.tryEmit(size)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package no.nordicsemi.android.broadcast
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user