diff options
Diffstat (limited to 'merchant-terminal')
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 -> |