Add methods to remember the currently selected Spinner's Asset and make sure that selection is not lost when the balances table is updated. Make an improvement to the camera feed UI.
This commit is contained in:
parent
2aa685d1da
commit
5388e90331
3 changed files with 32 additions and 3 deletions
|
@ -7,6 +7,7 @@ import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.AdapterView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
@ -40,6 +41,8 @@ class SendTransactionFragment : Fragment(), ZXingScannerView.ResultHandler {
|
||||||
|
|
||||||
private var mAssetsAdapter: AssetsAdapter? = null
|
private var mAssetsAdapter: AssetsAdapter? = null
|
||||||
|
|
||||||
|
private var selectedAssetSymbol = ""
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.fragment_send_transaction, container, false)
|
return inflater.inflate(R.layout.fragment_send_transaction, container, false)
|
||||||
|
@ -59,7 +62,25 @@ class SendTransactionFragment : Fragment(), ZXingScannerView.ResultHandler {
|
||||||
mBalancesDetails = balancesDetails
|
mBalancesDetails = balancesDetails
|
||||||
mAssetsAdapter = AssetsAdapter(context!!, android.R.layout.simple_spinner_item, mBalancesDetails!!)
|
mAssetsAdapter = AssetsAdapter(context!!, android.R.layout.simple_spinner_item, mBalancesDetails!!)
|
||||||
spAsset.adapter = mAssetsAdapter
|
spAsset.adapter = mAssetsAdapter
|
||||||
|
|
||||||
|
// Try to select the selectedAssetSymbol
|
||||||
|
for (i in 0 until mAssetsAdapter!!.count) {
|
||||||
|
if (mAssetsAdapter!!.getItem(i)!!.symbol == selectedAssetSymbol) {
|
||||||
|
spAsset.setSelection(i)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
spAsset.onItemSelectedListener = object : AdapterView.OnItemSelectedListener{
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>?) { }
|
||||||
|
|
||||||
|
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
|
selectedAssetSymbol = mAssetsAdapter!!.getItem(position)!!.symbol
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fabSendTransaction.setOnClickListener { validateFields() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun verifyCameraPermission() {
|
private fun verifyCameraPermission() {
|
||||||
|
@ -140,6 +161,10 @@ class SendTransactionFragment : Fragment(), ZXingScannerView.ResultHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun validateFields() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
if (isCameraPreviewVisible)
|
if (isCameraPreviewVisible)
|
||||||
|
|
5
app/src/main/res/drawable/camera_view_background.xml
Normal file
5
app/src/main/res/drawable/camera_view_background.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<corners android:radius="10dp" />
|
||||||
|
<solid android:color="#111" />
|
||||||
|
</shape>
|
|
@ -123,12 +123,11 @@
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/viewCamera"
|
android:id="@+id/viewCamera"
|
||||||
android:background="@color/black"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="@dimen/spacing_same_topic"
|
android:layout_marginTop="@dimen/spacing_same_topic"
|
||||||
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||||
android:visibility="visible"
|
android:background="@drawable/camera_view_background"
|
||||||
app:layout_constraintDimensionRatio="1:1"
|
app:layout_constraintDimensionRatio="1:1"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tvScan"
|
app:layout_constraintTop_toBottomOf="@+id/tvScan"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
@ -166,7 +165,7 @@
|
||||||
app:layout_constraintBottom_toBottomOf="@id/viewCamera"/>
|
app:layout_constraintBottom_toBottomOf="@id/viewCamera"/>
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/btnSend"
|
android:id="@+id/fabSendTransaction"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="15dp"
|
android:layout_marginTop="15dp"
|
||||||
|
|
Loading…
Reference in a new issue