-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix username creation bugs and remove some ANR's #1350
Merged
Merged
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6971acb
fix: remove metadataHandler and use coroutines to avoid ANR
HashEngineering 0a593bb
fix: handle several username creation bugs
HashEngineering 4fb3b50
fix: handle LockScreenActivity ANR with backup reminder
HashEngineering a037f1e
fix: sort transaction group tx's by date
HashEngineering ad6dbc5
fix: prevent ANR's in WalletMostRecentTransactionsObserver
HashEngineering ef127ea
fix: improve updating views based on balance changes
HashEngineering db582b1
fix: update to dashj 1.7.3-SNAPSHOT for username creation fixes
HashEngineering a6ce6ab
fix: disable tx metadata
HashEngineering 15c7a14
refactor: create WalletBalanceObserver instance in WalletApplication
HashEngineering e16f16c
fix: improve loading tx view
HashEngineering 1f5135a
fix: fixed issue that would create a topup during username creation
HashEngineering 0637006
fix: first emit the last balance
HashEngineering 19910b3
fix: first emit the last balance
HashEngineering 4b3d0a8
refactor: rename observeBalance() to observeTotalBalance()
HashEngineering 20cd511
fix: update WalletBalanceObserver on send/receive
HashEngineering f246f1f
fix: add mutex for the check() function and make sure that it execute…
HashEngineering e7f2b9e
fix: fix rescan and reset functions
HashEngineering File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,27 +19,35 @@ package de.schildbach.wallet.transactions | |
|
||
import de.schildbach.wallet.Constants | ||
import de.schildbach.wallet.util.ThrottlingWalletChangeListener | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.SupervisorJob | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import kotlinx.coroutines.launch | ||
import org.bitcoinj.core.Coin | ||
import org.bitcoinj.core.Transaction | ||
import org.bitcoinj.utils.Threading | ||
import org.bitcoinj.wallet.Wallet | ||
|
||
class WalletMostRecentTransactionsObserver(private val wallet: Wallet) { | ||
private val workerJob = SupervisorJob() | ||
private val workerScope = CoroutineScope(Dispatchers.IO + workerJob) | ||
fun observe(): Flow<Transaction> = callbackFlow { | ||
fun emitMostRecentTransaction() { | ||
org.bitcoinj.core.Context.propagate(Constants.CONTEXT) | ||
val allTxs = wallet.walletTransactions | ||
if (allTxs.any()) { | ||
var mostRecentTx = allTxs.first() | ||
allTxs.forEach { | ||
if (it.transaction.updateTime > mostRecentTx.transaction.updateTime) { | ||
mostRecentTx = it | ||
workerScope.launch { | ||
org.bitcoinj.core.Context.propagate(Constants.CONTEXT) | ||
val allTxs = wallet.walletTransactions | ||
if (allTxs.any()) { | ||
var mostRecentTx = allTxs.first() | ||
allTxs.forEach { | ||
if (it.transaction.updateTime > mostRecentTx.transaction.updateTime) { | ||
mostRecentTx = it | ||
} | ||
} | ||
trySend(mostRecentTx.transaction) | ||
Comment on lines
+39
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid an ANR when starting the app |
||
} | ||
trySend(mostRecentTx.transaction) | ||
} | ||
} | ||
|
||
|
@@ -84,6 +92,7 @@ class WalletMostRecentTransactionsObserver(private val wallet: Wallet) { | |
wallet.removeCoinsSentEventListener(walletChangeListener) | ||
wallet.removeCoinsReceivedEventListener(walletChangeListener) | ||
walletChangeListener.removeCallbacks() | ||
workerJob.cancel() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,7 @@ class TransactionGroupViewModel @Inject constructor( | |
TransactionRowView.fromTransaction( | ||
it, walletData.wallet!!, walletData.wallet!!.context, txMetadata, null, resourceMapper, chainLockBlockHeight | ||
) | ||
} | ||
}.sortedBy { row -> row.time } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sort TX in a group by date. |
||
_dashValue.value = transactionWrapper.getValue(walletData.transactionBag) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use coroutine instead of a Handler()