aboutsummaryrefslogtreecommitdiff
path: root/merchant-terminal
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-09-08 16:49:28 -0300
committerTorsten Grote <t@grobox.de>2020-09-08 16:49:28 -0300
commitd351f89cce722485033711f90edaf5a0f28e81ae (patch)
tree50746414671125d5c35b3da8ae6799b8bc62c3c1 /merchant-terminal
parent310775d1cb7a177641c704efb1a98a7ccaac67b3 (diff)
downloadtaler-android-d351f89cce722485033711f90edaf5a0f28e81ae.tar.gz
taler-android-d351f89cce722485033711f90edaf5a0f28e81ae.tar.bz2
taler-android-d351f89cce722485033711f90edaf5a0f28e81ae.zip
Fix minor lint warnings
Diffstat (limited to 'merchant-terminal')
-rw-r--r--merchant-terminal/src/main/java/net/taler/merchantpos/history/HistoryFragment.kt9
-rw-r--r--merchant-terminal/src/main/java/net/taler/merchantpos/refund/RefundFragment.kt12
2 files changed, 9 insertions, 12 deletions
diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/history/HistoryFragment.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/history/HistoryFragment.kt
index 3ef48e1..c7cd8ba 100644
--- a/merchant-terminal/src/main/java/net/taler/merchantpos/history/HistoryFragment.kt
+++ b/merchant-terminal/src/main/java/net/taler/merchantpos/history/HistoryFragment.kt
@@ -26,10 +26,9 @@ import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.DividerItemDecoration.VERTICAL
import androidx.recyclerview.widget.LinearLayoutManager
-import com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG
-import com.google.android.material.snackbar.Snackbar
import net.taler.common.exhaustive
import net.taler.common.navigate
+import net.taler.common.showError
import net.taler.merchantlib.OrderHistoryEntry
import net.taler.merchantpos.MainViewModel
import net.taler.merchantpos.databinding.FragmentMerchantHistoryBinding
@@ -81,7 +80,7 @@ class HistoryFragment : Fragment(), RefundClickListener {
})
historyManager.items.observe(viewLifecycleOwner, { result ->
when (result) {
- is HistoryResult.Error -> onError(result.msg)
+ is HistoryResult.Error -> requireActivity().showError(result.msg)
is HistoryResult.Success -> historyListAdapter.setData(result.items)
}.exhaustive
})
@@ -96,10 +95,6 @@ class HistoryFragment : Fragment(), RefundClickListener {
}
}
- private fun onError(msg: String) {
- Snackbar.make(requireView(), msg, LENGTH_LONG).show()
- }
-
override fun onRefundClicked(item: OrderHistoryEntry) {
refundManager.startRefund(item)
navigate(actionNavHistoryToRefundFragment())
diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/refund/RefundFragment.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/refund/RefundFragment.kt
index 91e68e6..5306b2f 100644
--- a/merchant-terminal/src/main/java/net/taler/merchantpos/refund/RefundFragment.kt
+++ b/merchant-terminal/src/main/java/net/taler/merchantpos/refund/RefundFragment.kt
@@ -20,6 +20,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.annotation.StringRes
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
@@ -28,6 +29,7 @@ import com.google.android.material.snackbar.Snackbar
import net.taler.common.fadeIn
import net.taler.common.fadeOut
import net.taler.common.navigate
+import net.taler.common.showError
import net.taler.lib.common.Amount
import net.taler.lib.common.AmountParserException
import net.taler.merchantlib.OrderHistoryEntry
@@ -89,9 +91,9 @@ class RefundFragment : Fragment() {
}
private fun onRefundResultChanged(result: RefundResult?): Any = when (result) {
- is Error -> onError(result.msg)
- PastDeadline -> onError(getString(R.string.refund_error_deadline))
- AlreadyRefunded -> onError(getString(R.string.refund_error_already_refunded))
+ is Error -> onError(R.string.refund_error_backend, result.msg)
+ PastDeadline -> onError(R.string.refund_error_deadline)
+ AlreadyRefunded -> onError(R.string.refund_error_already_refunded)
is Success -> {
ui.progressBar.fadeOut()
ui.refundButton.fadeIn()
@@ -101,8 +103,8 @@ class RefundFragment : Fragment() {
}
}
- private fun onError(msg: String) {
- Snackbar.make(requireView(), msg, LENGTH_LONG).show()
+ private fun onError(@StringRes main: Int, details: String = "") {
+ requireActivity().showError(main, details)
ui.progressBar.fadeOut()
ui.refundButton.fadeIn()
}