Minor tweaks and improvements.

This commit is contained in:
Kevin Gorham 2020-03-27 16:43:08 -04:00
parent ae41bd50cf
commit 27efadc218
No known key found for this signature in database
GPG Key ID: CCA55602DF49FC38
5 changed files with 28 additions and 23 deletions

View File

@ -17,7 +17,7 @@ class SynchronizerModule {
@Provides @Provides
@SynchronizerScope @SynchronizerScope
fun provideSynchronizer(appContext: Context, initializer: Initializer): Synchronizer { fun provideSynchronizer(appContext: Context, initializer: Initializer): Synchronizer {
return Synchronizer(appContext, initializer) return Synchronizer(initializer)
} }
} }

View File

@ -22,6 +22,10 @@ fun View.disabledIf(isDisabled: Boolean) {
isEnabled = !isDisabled isEnabled = !isDisabled
} }
fun View.transparentIf(isTransparent: Boolean) {
alpha = if (isTransparent) 0.0f else 1.0f
}
fun View.onClickNavTo(navResId: Int, block: (() -> Any) = {}) { fun View.onClickNavTo(navResId: Int, block: (() -> Any) = {}) {
setOnClickListener { setOnClickListener {
block() block()

View File

@ -50,7 +50,6 @@ import javax.inject.Inject
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
@Inject @Inject
lateinit var feedback: Feedback lateinit var feedback: Feedback
@ -324,6 +323,7 @@ class MainActivity : AppCompatActivity() {
showSnackbar("Well, this is awkward. You denied permission for the camera.") showSnackbar("Well, this is awkward. You denied permission for the camera.")
} }
// TODO: clean up this error handling
private var ignoredErrors = 0 private var ignoredErrors = 0
private fun onProcessorError(error: Throwable?): Boolean { private fun onProcessorError(error: Throwable?): Boolean {
var notified = false var notified = false
@ -368,25 +368,25 @@ class MainActivity : AppCompatActivity() {
} }
if (!notified) { if (!notified) {
ignoredErrors++ ignoredErrors++
} if (ignoredErrors >= ZcashSdk.RETRIES) {
if (ignoredErrors >= ZcashSdk.RETRIES) { if (dialog == null) {
if (dialog == null) { notified = true
notified = true runOnUiThread {
runOnUiThread { dialog = MaterialAlertDialogBuilder(this)
dialog = MaterialAlertDialogBuilder(this) .setTitle("Processor Error")
.setTitle("Processor Error") .setMessage(error?.message ?: "Critical error while processing blocks!")
.setMessage(error?.message ?: "Critical error while processing blocks!") .setCancelable(false)
.setCancelable(false) .setPositiveButton("Retry") { d, _ ->
.setPositiveButton("Retry") { d, _ -> d.dismiss()
d.dismiss() dialog = null
dialog = null }
} .setNegativeButton("Exit") { dialog, _ ->
.setNegativeButton("Exit") { dialog, _ -> dialog.dismiss()
dialog.dismiss() throw error
throw error ?: RuntimeException("Critical error while processing blocks and the user chose to exit.")
?: RuntimeException("Critical error while processing blocks and the user chose to exit.") }
} .show()
.show() }
} }
} }
} }

View File

@ -66,6 +66,7 @@ class WalletDetailFragment : BaseFragment<FragmentDetailBinding>() {
adapter = TransactionAdapter() adapter = TransactionAdapter()
viewModel.transactions.collectWith(resumedScope) { onTransactionsUpdated(it) } viewModel.transactions.collectWith(resumedScope) { onTransactionsUpdated(it) }
binding.recyclerTransactions.adapter = adapter binding.recyclerTransactions.adapter = adapter
binding.recyclerTransactions.smoothScrollToPosition(0)
} }
private fun onTransactionsUpdated(transactions: PagedList<ConfirmedTransaction>) { private fun onTransactionsUpdated(transactions: PagedList<ConfirmedTransaction>) {

View File

@ -13,6 +13,7 @@ import cash.z.ecc.android.feedback.Report.MetricType
import cash.z.ecc.android.feedback.Report.MetricType.* import cash.z.ecc.android.feedback.Report.MetricType.*
import cash.z.ecc.android.lockbox.LockBox import cash.z.ecc.android.lockbox.LockBox
import cash.z.ecc.android.ui.setup.WalletSetupViewModel import cash.z.ecc.android.ui.setup.WalletSetupViewModel
import cash.z.ecc.android.ui.util.INCLUDE_MEMO_PREFIX
import cash.z.wallet.sdk.Initializer import cash.z.wallet.sdk.Initializer
import cash.z.wallet.sdk.Synchronizer import cash.z.wallet.sdk.Synchronizer
import cash.z.wallet.sdk.entity.* import cash.z.wallet.sdk.entity.*
@ -76,7 +77,7 @@ class SendViewModel @Inject constructor() : ViewModel() {
} }
} }
fun createMemoToSend() = if (includeFromAddress) "$memo\nsent from\n$fromAddress" else memo fun createMemoToSend() = if (includeFromAddress) "$memo\n$INCLUDE_MEMO_PREFIX\n$fromAddress" else memo
private fun reportIssues(memoToSend: String) { private fun reportIssues(memoToSend: String) {
if (toAddress == fromAddress) feedback.report(Issue.SelfSend) if (toAddress == fromAddress) feedback.report(Issue.SelfSend)
@ -196,7 +197,6 @@ class SendViewModel @Inject constructor() : ViewModel() {
private fun Keyed<String>.toMetricIdFor(id: Long): String = "$id.$key" private fun Keyed<String>.toMetricIdFor(id: Long): String = "$id.$key"
private fun String.toRelatedMetricId(): String = "$this.related" private fun String.toRelatedMetricId(): String = "$this.related"
private fun String.toTxId(): Long = split('.').first().toLong() private fun String.toTxId(): Long = split('.').first().toLong()
} }