2019-10-21 03:17:07 -07:00
|
|
|
package cash.z.wallet.sdk.demoapp.demos.getaddress
|
|
|
|
|
|
|
|
import android.view.LayoutInflater
|
2019-11-01 13:25:28 -07:00
|
|
|
import cash.z.wallet.sdk.Initializer
|
2019-10-21 03:17:07 -07:00
|
|
|
import cash.z.wallet.sdk.demoapp.App
|
|
|
|
import cash.z.wallet.sdk.demoapp.BaseDemoFragment
|
|
|
|
import cash.z.wallet.sdk.demoapp.databinding.FragmentGetAddressBinding
|
|
|
|
|
2020-02-27 00:25:07 -08:00
|
|
|
/**
|
|
|
|
* Displays the address associated with the seed defined by the default config. To modify the seed
|
|
|
|
* that is used, update the `DemoConfig.seedWords` value.
|
|
|
|
*/
|
2019-10-21 03:17:07 -07:00
|
|
|
class GetAddressFragment : BaseDemoFragment<FragmentGetAddressBinding>() {
|
|
|
|
|
2020-02-25 23:43:27 -08:00
|
|
|
private var seed: ByteArray = App.instance.defaultConfig.seed
|
|
|
|
private val initializer: Initializer = Initializer(App.instance)
|
|
|
|
|
|
|
|
private lateinit var address: String
|
2019-10-21 03:17:07 -07:00
|
|
|
|
|
|
|
override fun inflateBinding(layoutInflater: LayoutInflater): FragmentGetAddressBinding
|
|
|
|
= FragmentGetAddressBinding.inflate(layoutInflater)
|
|
|
|
|
|
|
|
override fun resetInBackground() {
|
2020-02-25 23:43:27 -08:00
|
|
|
address = initializer.deriveAddress(seed)
|
2019-10-21 03:17:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun onResetComplete() {
|
2020-02-25 23:43:27 -08:00
|
|
|
binding.textInfo.text = address
|
2019-10-21 03:17:07 -07:00
|
|
|
}
|
|
|
|
|
2020-02-25 23:43:27 -08:00
|
|
|
override fun onActionButtonClicked() {
|
|
|
|
copyToClipboard(address)
|
2019-10-21 03:17:07 -07:00
|
|
|
}
|
2020-02-25 23:43:27 -08:00
|
|
|
|
2019-10-21 03:17:07 -07:00
|
|
|
}
|