adicionando PrintService
This commit is contained in:
parent
8ae270b625
commit
083d642186
@ -36,6 +36,10 @@ class AditumSdkService(private val paymentApplication: PaymentApplication) {
|
|||||||
|
|
||||||
fun getName(): String = "AditumSdkModule"
|
fun getName(): String = "AditumSdkModule"
|
||||||
|
|
||||||
|
fun register() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fun initAditumSdk(
|
fun initAditumSdk(
|
||||||
applicationName: String,
|
applicationName: String,
|
||||||
applicationVersion: String,
|
applicationVersion: String,
|
||||||
|
|||||||
40
app/src/main/java/com/example/mypos/services/PrintService.kt
Normal file
40
app/src/main/java/com/example/mypos/services/PrintService.kt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package com.example.mypos.services
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.util.Log
|
||||||
|
import br.com.aditum.data.v2.enums.PrintStatus
|
||||||
|
import br.com.aditum.device.callbacks.IPrintStatusCallback
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
class PrintService(private val paymentApplication: PaymentApplication) {
|
||||||
|
companion object {
|
||||||
|
private const val TAG = "PrintService"
|
||||||
|
}
|
||||||
|
private val coroutineScope = CoroutineScope(Dispatchers.IO)
|
||||||
|
|
||||||
|
private val _printStatusFlow = MutableStateFlow(null)
|
||||||
|
val printStatusFlow: StateFlow<PrintStatus?> = _printStatusFlow.asStateFlow()
|
||||||
|
|
||||||
|
private val callback = object : IPrintStatusCallback.Stub() {
|
||||||
|
override fun finished(printStatus: PrintStatus?) {
|
||||||
|
coroutineScope.launch {
|
||||||
|
Log.d(TAG, "PrintStatus - $printStatus")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun print(vararg bitmaps: Bitmap) {
|
||||||
|
bitmaps.forEach { bitmap ->
|
||||||
|
paymentApplication.communicationService?.deviceSdk?.printerSdk?.print(
|
||||||
|
bitmap,
|
||||||
|
callback
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user