In ReceiveTransactionFragment, add an 'Other...' option at the end of the assets spinner and when the user selects it an AutoCompleteTextView appears below where the user can select other asset, the AutoCompleteTextView suggestions will be backed by BitShares node queries to show matching Assets.
This commit is contained in:
parent
e8ec0e6f89
commit
8fd7c28256
2 changed files with 45 additions and 26 deletions
|
@ -38,6 +38,8 @@ import java.util.concurrent.TimeUnit
|
|||
class ReceiveTransactionFragment : Fragment() {
|
||||
private val TAG = this.javaClass.simpleName
|
||||
|
||||
private val OTHER_ASSET = "other_asset"
|
||||
|
||||
private lateinit var mUserAccountViewModel: UserAccountViewModel
|
||||
private lateinit var mAssetViewModel: AssetViewModel
|
||||
|
||||
|
@ -50,7 +52,7 @@ class ReceiveTransactionFragment : Fragment() {
|
|||
|
||||
private var mAssetsAdapter: AssetsAdapter? = null
|
||||
|
||||
private var mAssets: List<cy.agorise.bitsybitshareswallet.database.entities.Asset>? = null
|
||||
private var mAssets = ArrayList<cy.agorise.bitsybitshareswallet.database.entities.Asset>()
|
||||
|
||||
private var selectedAssetSymbol = ""
|
||||
|
||||
|
@ -72,12 +74,21 @@ class ReceiveTransactionFragment : Fragment() {
|
|||
mUserAccount = UserAccount(user.id, user.name)
|
||||
})
|
||||
|
||||
// Configure Assets spinner to show Assets already saved into the db
|
||||
mAssetViewModel = ViewModelProviders.of(this).get(AssetViewModel::class.java)
|
||||
|
||||
mAssetViewModel.getAll().observe(this,
|
||||
Observer<List<cy.agorise.bitsybitshareswallet.database.entities.Asset>> { assets ->
|
||||
mAssets = assets
|
||||
mAssetsAdapter = AssetsAdapter(context!!, android.R.layout.simple_spinner_item, mAssets!!)
|
||||
mAssets.clear()
|
||||
mAssets.addAll(assets)
|
||||
|
||||
// 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(
|
||||
OTHER_ASSET, "Other...", 0, "", ""
|
||||
)
|
||||
mAssets.add(asset)
|
||||
|
||||
mAssetsAdapter = AssetsAdapter(context!!, android.R.layout.simple_spinner_item, mAssets)
|
||||
spAsset.adapter = mAssetsAdapter
|
||||
|
||||
// Try to select the selectedAssetSymbol
|
||||
|
@ -94,9 +105,16 @@ class ReceiveTransactionFragment : Fragment() {
|
|||
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
val asset = mAssetsAdapter!!.getItem(position)!!
|
||||
|
||||
if (asset.id == OTHER_ASSET) {
|
||||
tilAsset.visibility = View.VISIBLE
|
||||
mAsset = null
|
||||
} else {
|
||||
tilAsset.visibility = View.GONE
|
||||
selectedAssetSymbol = asset.symbol
|
||||
|
||||
mAsset = Asset(asset.id, asset.symbol, asset.precision)
|
||||
}
|
||||
updateQR()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,28 +59,29 @@
|
|||
app:layout_constraintEnd_toEndOf="@+id/spAsset"
|
||||
app:layout_constraintStart_toStartOf="@+id/spAsset" />
|
||||
|
||||
<!--<com.google.android.material.textfield.TextInputLayout-->
|
||||
<!--style="@style/Widget.Bitsy.TextInputLayout"-->
|
||||
<!--android:layout_width="0dp"-->
|
||||
<!--android:layout_height="0dp"-->
|
||||
<!--android:layout_marginStart="12dp"-->
|
||||
<!--android:hint="@string/text__asset"-->
|
||||
<!--app:layout_constraintTop_toTopOf="@id/tilAmount"-->
|
||||
<!--app:layout_constraintBottom_toBottomOf="@id/tilAmount"-->
|
||||
<!--app:layout_constraintStart_toEndOf="@id/centeredVerticalGuideline"-->
|
||||
<!--app:layout_constraintEnd_toEndOf="parent">-->
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/tilAsset"
|
||||
style="@style/Widget.Bitsy.TextInputLayout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/spacing_same_topic"
|
||||
android:visibility="gone"
|
||||
android:hint="@string/text__asset"
|
||||
app:layout_constraintTop_toBottomOf="@id/tilAmount"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<!--<cy.agorise.bitsybitshareswallet.views.MyTextInputAutoCompleteTextView-->
|
||||
<!--android:id="@+id/actvAsset"-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:layout_height="match_parent"-->
|
||||
<!--android:paddingStart="12dp"-->
|
||||
<!--android:paddingEnd="8dp"-->
|
||||
<!--android:maxLines="1"-->
|
||||
<!--android:lines="1"-->
|
||||
<!--android:imeOptions="actionDone"/>-->
|
||||
<cy.agorise.bitsybitshareswallet.views.MyTextInputAutoCompleteTextView
|
||||
android:id="@+id/actvAsset"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:maxLines="1"
|
||||
android:lines="1"
|
||||
android:imeOptions="actionDone"/>
|
||||
|
||||
<!--</com.google.android.material.textfield.TextInputLayout>-->
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivQR"
|
||||
|
@ -90,7 +91,7 @@
|
|||
android:layout_marginBottom="@dimen/spacing_different_topic"
|
||||
android:background="@drawable/camera_view_background"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintTop_toBottomOf="@id/tilAmount"
|
||||
app:layout_constraintTop_toBottomOf="@id/tilAsset"
|
||||
app:layout_constraintBottom_toTopOf="@id/tvPleasePay"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
|
Loading…
Reference in a new issue