aboutsummaryrefslogtreecommitdiff
path: root/merchant-terminal
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2021-12-07 20:04:27 -0300
committerTorsten Grote <t@grobox.de>2021-12-07 20:04:27 -0300
commit71be094780464c2b97a4cb6b33dd7f465647c082 (patch)
treef21da1ec79e3599957b2f048064ff23f652d88af /merchant-terminal
parent72813a244580285ab268a6257097ece4e73bbb14 (diff)
downloadtaler-android-71be094780464c2b97a4cb6b33dd7f465647c082.tar.gz
taler-android-71be094780464c2b97a4cb6b33dd7f465647c082.tar.bz2
taler-android-71be094780464c2b97a4cb6b33dd7f465647c082.zip
Set LiveData to be nullable after library update
Diffstat (limited to 'merchant-terminal')
-rw-r--r--merchant-terminal/src/main/java/net/taler/merchantpos/order/LiveOrder.kt6
-rw-r--r--merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderFragment.kt1
-rw-r--r--merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderStateFragment.kt1
3 files changed, 5 insertions, 3 deletions
diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/order/LiveOrder.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/order/LiveOrder.kt
index 10aabd4..f48c1db 100644
--- a/merchant-terminal/src/main/java/net/taler/merchantpos/order/LiveOrder.kt
+++ b/merchant-terminal/src/main/java/net/taler/merchantpos/order/LiveOrder.kt
@@ -31,7 +31,7 @@ import net.taler.merchantpos.order.RestartState.UNDO
internal enum class RestartState { ENABLED, DISABLED, UNDO }
internal interface LiveOrder {
- val order: LiveData<Order>
+ val order: LiveData<Order?>
val orderTotal: LiveData<Amount>
val restartState: LiveData<RestartState>
val modifyOrderAllowed: LiveData<Boolean>
@@ -50,9 +50,9 @@ internal class MutableLiveOrder(
) : LiveOrder {
private val availableCategories: Map<Int, Category>
get() = productsByCategory.keys.map { it.id to it }.toMap()
- override val order: MutableLiveData<Order> =
+ override val order: MutableLiveData<Order?> =
MutableLiveData(Order(id, currency, availableCategories))
- override val orderTotal: LiveData<Amount> = Transformations.map(order) { it.total }
+ override val orderTotal: LiveData<Amount> = Transformations.map(order) { it?.total }
override val restartState = MutableLiveData(DISABLED)
private val selectedOrderLine = MutableLiveData<ConfigProduct?>()
override val selectedProductKey: String?
diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderFragment.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderFragment.kt
index 1335b65..25a1874 100644
--- a/merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderFragment.kt
+++ b/merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderFragment.kt
@@ -75,6 +75,7 @@ class OrderFragment : Fragment() {
private fun onOrderSwitched(orderId: Int, liveOrder: LiveOrder) {
// order title
liveOrder.order.observe(viewLifecycleOwner, { order ->
+ if (order == null) return@observe
activity?.title = getString(R.string.order_label_title, order.title)
})
// restart button
diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderStateFragment.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderStateFragment.kt
index 93c4f97..d86f504 100644
--- a/merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderStateFragment.kt
+++ b/merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderStateFragment.kt
@@ -83,6 +83,7 @@ class OrderStateFragment : Fragment() {
}
})
liveOrder.order.observe(viewLifecycleOwner, { order ->
+ if (order == null) return@observe
onOrderChanged(order, tracker)
})
liveOrder.orderTotal.observe(viewLifecycleOwner, { orderTotal ->