From 262a0d58ad28f6b63f4694454310198422e8c15b Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Sun, 3 Feb 2019 18:13:00 -0500 Subject: [PATCH] - Automatically setting the bts_value column for BTS transfers. --- .../bitsybitshareswallet/activities/ConnectedActivity.kt | 6 +++--- .../bitsybitshareswallet/database/entities/Transfer.kt | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/ConnectedActivity.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/ConnectedActivity.kt index 6273de2..5d79aaf 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/ConnectedActivity.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/ConnectedActivity.kt @@ -147,7 +147,6 @@ abstract class ConnectedActivity : AppCompatActivity(), ServiceConnection { mTransferViewModel.getTransferBlockNumberWithMissingTime().observe(this, Observer{ blockNumber -> if (blockNumber != null && blockNumber != blockNumberWithMissingTime) { blockNumberWithMissingTime = blockNumber - Log.d(TAG, "Block number: $blockNumber, Time: ${System.currentTimeMillis()}") mHandler.post(mRequestBlockMissingTimeTask) } }) @@ -251,7 +250,6 @@ abstract class ConnectedActivity : AppCompatActivity(), ServiceConnection { */ private fun handleTransfersWithMissingBtsValue(transfer: Transfer) { if(mNetworkService?.isConnected == true){ - Log.d(TAG,"Transfer: ${transfer}") val base = Asset(transfer.transferAssetId) val quote = Asset("1.3.0") val bucket: Long = TimeUnit.SECONDS.convert(1, TimeUnit.DAYS) @@ -373,7 +371,9 @@ abstract class ConnectedActivity : AppCompatActivity(), ServiceConnection { val disposable = Observable.just(pair) .subscribeOn(Schedulers.computation()) .map { mTransferViewModel.updateBtsValue(it.first!!, it.second) } - .subscribe({},{ Log.e(TAG,"Error at updateBtsValue. Msg: ${it.message}") + .subscribe({},{ + Log.e(TAG,"Error at updateBtsValue. Msg: ${it.message}") + for(line in it.stackTrace) Log.e(TAG, "${line.className}#${line.methodName}:${line.lineNumber}") }) mCompositeDisposable.add(disposable) }else{ diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/entities/Transfer.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/entities/Transfer.kt index 37f9e4a..1505a16 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/entities/Transfer.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/entities/Transfer.kt @@ -25,4 +25,10 @@ data class Transfer ( // Constant used to specify a BTS equivalent value whose calculation returned an error val ERROR: Long? = -2L } + init { + if(transferAssetId.equals("1.3.0")){ + // If the transferred asset is BTS, we can fill the btsValue field immediately + btsValue = transferAmount + } + } } \ No newline at end of file