Order assets alphabetically on Spinners in ReceiveTransactionFragment, SendTransactionFragment and TransactionsFragment's FilterOptionsDialog, always trying to select BTS by default.
This commit is contained in:
parent
a8fe1ed2c5
commit
032c627725
3 changed files with 21 additions and 6 deletions
|
@ -21,6 +21,7 @@ import cy.agorise.bitsybitshareswallet.views.DatePickerFragment
|
|||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import kotlin.ClassCastException
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
|
||||
/**
|
||||
|
@ -100,6 +101,8 @@ class FilterOptionsDialog : DialogFragment() {
|
|||
// */
|
||||
// private val mUserCurrency = RuntimeData.EXTERNAL_CURRENCY
|
||||
|
||||
private var mBalanceDetails = ArrayList<BalanceDetail>()
|
||||
|
||||
private lateinit var mBalanceDetailViewModel: BalanceDetailViewModel
|
||||
|
||||
private var mBalancesDetailsAdapter: BalancesDetailsAdapter? = null
|
||||
|
@ -218,7 +221,12 @@ class FilterOptionsDialog : DialogFragment() {
|
|||
mBalanceDetailViewModel = ViewModelProviders.of(this).get(BalanceDetailViewModel::class.java)
|
||||
|
||||
mBalanceDetailViewModel.getAll().observe(this, Observer<List<BalanceDetail>> { balancesDetails ->
|
||||
mBalancesDetailsAdapter = BalancesDetailsAdapter(context!!, android.R.layout.simple_spinner_item, balancesDetails!!)
|
||||
mBalanceDetails.clear()
|
||||
mBalanceDetails.addAll(balancesDetails)
|
||||
mBalanceDetails.sortWith(
|
||||
Comparator { a, b -> a.toString().compareTo(b.toString(), true) }
|
||||
)
|
||||
mBalancesDetailsAdapter = BalancesDetailsAdapter(context!!, android.R.layout.simple_spinner_item, mBalanceDetails)
|
||||
sAsset.adapter = mBalancesDetailsAdapter
|
||||
|
||||
val assetSelected = arguments!!.getString(KEY_FILTER_ASSET)
|
||||
|
|
|
@ -72,7 +72,7 @@ class ReceiveTransactionFragment : ConnectedFragment() {
|
|||
private var mAssets = ArrayList<cy.agorise.bitsybitshareswallet.database.entities.Asset>()
|
||||
|
||||
/** Keeps track of the current selected asset symbol */
|
||||
private var selectedAssetSymbol = ""
|
||||
private var selectedAssetSymbol = "BTS"
|
||||
|
||||
/** Used to avoid erasing the QR code when the user selects an item from the AutoComplete suggestions */
|
||||
private var selectedInAutoCompleteTextView = false
|
||||
|
@ -119,6 +119,9 @@ class ReceiveTransactionFragment : ConnectedFragment() {
|
|||
Observer<List<cy.agorise.bitsybitshareswallet.database.entities.Asset>> { assets ->
|
||||
mAssets.clear()
|
||||
mAssets.addAll(assets)
|
||||
mAssets.sortWith(
|
||||
Comparator { a, b -> a.toString().compareTo(b.toString(), true) }
|
||||
)
|
||||
|
||||
// Add an option at the end so the user can search for an asset other than the ones saved in the db
|
||||
val asset = cy.agorise.bitsybitshareswallet.database.entities.Asset(
|
||||
|
|
|
@ -72,14 +72,14 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
|
|||
private var isToAccountCorrect = false
|
||||
private var isAmountCorrect = false
|
||||
|
||||
private var mBalancesDetails: List<BalanceDetail>? = null
|
||||
private var mBalancesDetails = ArrayList<BalanceDetail>()
|
||||
|
||||
private lateinit var mBalanceDetailViewModel: BalanceDetailViewModel
|
||||
|
||||
private var mBalancesDetailsAdapter: BalancesDetailsAdapter? = null
|
||||
|
||||
/** Keeps track of the asset's symbol selected in the Asset spinner */
|
||||
private var selectedAssetSymbol = ""
|
||||
private var selectedAssetSymbol = "BTS"
|
||||
|
||||
/** Current user account */
|
||||
private var mUserAccount: UserAccount? = null
|
||||
|
@ -144,8 +144,12 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
|
|||
mBalanceDetailViewModel = ViewModelProviders.of(this).get(BalanceDetailViewModel::class.java)
|
||||
|
||||
mBalanceDetailViewModel.getAll().observe(this, Observer<List<BalanceDetail>> { balancesDetails ->
|
||||
mBalancesDetails = balancesDetails
|
||||
mBalancesDetailsAdapter = BalancesDetailsAdapter(context!!, android.R.layout.simple_spinner_item, mBalancesDetails!!)
|
||||
mBalancesDetails.clear()
|
||||
mBalancesDetails.addAll(balancesDetails)
|
||||
mBalancesDetails.sortWith(
|
||||
Comparator { a, b -> a.toString().compareTo(b.toString(), true) }
|
||||
)
|
||||
mBalancesDetailsAdapter = BalancesDetailsAdapter(context!!, android.R.layout.simple_spinner_item, mBalancesDetails)
|
||||
spAsset.adapter = mBalancesDetailsAdapter
|
||||
|
||||
// Try to select the selectedAssetSymbol
|
||||
|
|
Loading…
Reference in a new issue