Update material-dialogs library.
- Updated the material-dialogs library, and its usages to reflect the new code style 100% focused on Kotlin.
This commit is contained in:
parent
a42736b738
commit
3c0d2091d8
4 changed files with 48 additions and 57 deletions
|
@ -115,7 +115,7 @@ dependencies {
|
|||
implementation 'org.bitcoinj:bitcoinj-core:0.14.3'
|
||||
implementation 'com.moldedbits.r2d2:r2d2:1.0.1'
|
||||
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
|
||||
implementation 'com.afollestad.material-dialogs:core:2.0.0'
|
||||
implementation 'com.afollestad.material-dialogs:core:3.1.0'
|
||||
implementation 'com.andrognito.patternlockview:patternlockview:1.0.0'
|
||||
// Android Debug Database
|
||||
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
|
||||
|
|
|
@ -272,11 +272,11 @@ class CreateAccountFragment : BaseAccountFragment() {
|
|||
override fun onFailure(call: Call<FaucetResponse>, t: Throwable) {
|
||||
// the network call was a failure
|
||||
context?.let { context ->
|
||||
MaterialDialog(context)
|
||||
.title(R.string.title_error)
|
||||
.message(cy.agorise.bitsybitshareswallet.R.string.error__faucet)
|
||||
.negativeButton(android.R.string.ok)
|
||||
.show()
|
||||
MaterialDialog(context).show {
|
||||
title(R.string.title_error)
|
||||
message(R.string.error__faucet)
|
||||
negativeButton(android.R.string.ok)
|
||||
}
|
||||
}
|
||||
|
||||
setStateError()
|
||||
|
|
|
@ -29,10 +29,7 @@ import cy.agorise.graphenej.api.calls.GetKeyReferences
|
|||
import cy.agorise.graphenej.models.AccountProperties
|
||||
import cy.agorise.graphenej.models.DynamicGlobalProperties
|
||||
import cy.agorise.graphenej.models.JsonRpcResponse
|
||||
import cy.agorise.graphenej.network.FullNode
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlinx.android.synthetic.main.fragment_import_brainkey.*
|
||||
import org.bitcoinj.core.ECKey
|
||||
import java.text.NumberFormat
|
||||
|
@ -67,7 +64,7 @@ class ImportBrainkeyFragment : BaseAccountFragment() {
|
|||
private var mNodesDialog: MaterialDialog? = null
|
||||
|
||||
/** Adapter that holds the FullNode list used in the Bitshares nodes modal */
|
||||
private var mNodesAdapter: FullNodesAdapter? = null
|
||||
private var nodesAdapter: FullNodesAdapter? = null
|
||||
|
||||
/** Handler that will be used to make recurrent calls to get the latest BitShares block number*/
|
||||
private val mHandler = Handler()
|
||||
|
@ -129,31 +126,48 @@ class ImportBrainkeyFragment : BaseAccountFragment() {
|
|||
Navigation.createNavigateOnClickListener(R.id.create_account_action)
|
||||
)
|
||||
|
||||
tvNetworkStatus.setOnClickListener { v ->
|
||||
if (mNetworkService != null) {
|
||||
// PublishSubject used to announce full node latencies updates
|
||||
val fullNodePublishSubject = mNetworkService!!.nodeLatencyObservable
|
||||
fullNodePublishSubject?.observeOn(AndroidSchedulers.mainThread())?.subscribe(nodeLatencyObserver)
|
||||
tvNetworkStatus.setOnClickListener { v -> showNodesDialog(v) }
|
||||
}
|
||||
|
||||
private fun showNodesDialog(v: View) {
|
||||
if (mNetworkService != null) {
|
||||
val fullNodes = mNetworkService!!.nodes
|
||||
|
||||
mNodesAdapter = FullNodesAdapter(v.context)
|
||||
mNodesAdapter?.add(fullNodes)
|
||||
nodesAdapter = FullNodesAdapter(v.context)
|
||||
nodesAdapter?.add(fullNodes)
|
||||
|
||||
mNodesDialog = MaterialDialog(v.context)
|
||||
.title(text = String.format("%s v%s", getString(R.string.app_name), BuildConfig.VERSION_NAME))
|
||||
.message(text = getString(R.string.title__bitshares_nodes_dialog, "-------"))
|
||||
.customListAdapter(mNodesAdapter as FullNodesAdapter)
|
||||
.negativeButton(android.R.string.ok)
|
||||
.onDismiss { mHandler.removeCallbacks(mRequestDynamicGlobalPropertiesTask) }
|
||||
// PublishSubject used to announce full node latencies updates
|
||||
val fullNodePublishSubject = mNetworkService!!.nodeLatencyObservable ?: return
|
||||
|
||||
mNodesDialog?.show()
|
||||
val nodesDisposable = fullNodePublishSubject
|
||||
.subscribeOn(AndroidSchedulers.mainThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{ fullNode ->
|
||||
if (!fullNode.isRemoved)
|
||||
nodesAdapter?.add(fullNode)
|
||||
else
|
||||
nodesAdapter?.remove(fullNode)
|
||||
}, {
|
||||
Log.e(TAG, "nodeLatencyObserver.onError.Msg: " + it.message)
|
||||
}
|
||||
)
|
||||
|
||||
mNodesDialog = MaterialDialog(v.context).show {
|
||||
title(text = String.format("%s v%s", getString(R.string.app_name), BuildConfig.VERSION_NAME))
|
||||
message(text = getString(R.string.title__bitshares_nodes_dialog, "-------"))
|
||||
customListAdapter(nodesAdapter as FullNodesAdapter)
|
||||
negativeButton(android.R.string.ok)
|
||||
onDismiss {
|
||||
mHandler.removeCallbacks(mRequestDynamicGlobalPropertiesTask)
|
||||
nodesDisposable.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
// Registering a recurrent task used to poll for dynamic global properties requests
|
||||
mHandler.post(mRequestDynamicGlobalPropertiesTask)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun validatePIN() {
|
||||
val pin = tietPin.text.toString()
|
||||
|
@ -345,28 +359,6 @@ class ImportBrainkeyFragment : BaseAccountFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Observer used to be notified about node latency measurement updates.
|
||||
*/
|
||||
private val nodeLatencyObserver = object : Observer<FullNode> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
mDisposables.add(d)
|
||||
}
|
||||
|
||||
override fun onNext(fullNode: FullNode) {
|
||||
if (!fullNode.isRemoved)
|
||||
mNodesAdapter?.add(fullNode)
|
||||
else
|
||||
mNodesAdapter?.remove(fullNode)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, "nodeLatencyObserver.onError.Msg: " + e.message)
|
||||
}
|
||||
|
||||
override fun onComplete() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Task used to obtain frequent updates on the global dynamic properties object
|
||||
*/
|
||||
|
|
|
@ -170,17 +170,16 @@ class SettingsFragment : ConnectedFragment(), BaseSecurityLockDialog.OnPINPatter
|
|||
}
|
||||
)
|
||||
|
||||
mNodesDialog = MaterialDialog(v.context)
|
||||
.title(text = String.format("%s v%s", getString(R.string.app_name), BuildConfig.VERSION_NAME))
|
||||
.message(text = getString(R.string.title__bitshares_nodes_dialog, "-------"))
|
||||
.customListAdapter(nodesAdapter as FullNodesAdapter)
|
||||
.negativeButton(android.R.string.ok)
|
||||
.onDismiss {
|
||||
mNodesDialog = MaterialDialog(v.context).show {
|
||||
title(text = String.format("%s v%s", getString(R.string.app_name), BuildConfig.VERSION_NAME))
|
||||
message(text = getString(R.string.title__bitshares_nodes_dialog, "-------"))
|
||||
customListAdapter(nodesAdapter as FullNodesAdapter)
|
||||
negativeButton(android.R.string.ok)
|
||||
onDismiss {
|
||||
mHandler.removeCallbacks(mRequestDynamicGlobalPropertiesTask)
|
||||
nodesDisposable.dispose()
|
||||
}
|
||||
|
||||
mNodesDialog?.show()
|
||||
}
|
||||
|
||||
// Registering a recurrent task used to poll for dynamic global properties requests
|
||||
mHandler.post(mRequestDynamicGlobalPropertiesTask)
|
||||
|
|
Loading…
Reference in a new issue