aboutsummaryrefslogtreecommitdiff
path: root/wallet/src/main
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-05-13 10:11:11 -0300
committerTorsten Grote <t@grobox.de>2020-05-13 10:11:11 -0300
commitc435770450be207a1c598404115c3784a45a7b96 (patch)
tree99068ecd0befc7fbbd8f9b64d45985819f3d4f62 /wallet/src/main
parent508a12b8f7957dcf817fb2f29a6b924b22ebdc55 (diff)
downloadtaler-android-c435770450be207a1c598404115c3784a45a7b96.tar.gz
taler-android-c435770450be207a1c598404115c3784a45a7b96.tar.bz2
taler-android-c435770450be207a1c598404115c3784a45a7b96.zip
[wallet] switch to multi-currency mode when a new currency gets added
Diffstat (limited to 'wallet/src/main')
-rw-r--r--wallet/src/main/java/net/taler/wallet/MainFragment.kt9
1 files changed, 6 insertions, 3 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/MainFragment.kt b/wallet/src/main/java/net/taler/wallet/MainFragment.kt
index 0bc6084..2905238 100644
--- a/wallet/src/main/java/net/taler/wallet/MainFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainFragment.kt
@@ -30,6 +30,7 @@ import net.taler.wallet.transactions.TransactionsFragment
class MainFragment : Fragment() {
private val model: MainViewModel by activityViewModels()
+ private var currentTag: String? = null
override fun onCreateView(
inflater: LayoutInflater,
@@ -55,15 +56,17 @@ class MainFragment : Fragment() {
}
private fun onBalancesChanged(balances: List<BalanceItem>) {
- if (childFragmentManager.fragments.isEmpty()) {
- val f = if (balances.size == 1) {
+ val tag = if (balances.size == 1) "single" else "multi"
+ if (currentTag != tag) {
+ val f = if (tag == "single") {
model.transactionManager.selectedCurrency = balances[0].available.currency
TransactionsFragment()
} else {
BalancesFragment()
}
+ currentTag = tag
childFragmentManager.beginTransaction()
- .add(R.id.mainFragmentContainer, f)
+ .replace(R.id.mainFragmentContainer, f, tag)
.commitNow()
}
}