Check existence of selected block explorer using name string comparison

After further testing, I realized I introduced a bug in commit
4f4b0f6ce9 because apparently the
ArrayList.contains() method does not properly work for
BlockChainExplorer object - to fix this I implemented a new
contains() method that uses string comparison instead
This commit is contained in:
wiz 2020-01-04 02:55:01 +09:00
parent 4ac5450973
commit c0783205bb
No known key found for this signature in database
GPG key ID: A394E332255A6173

View file

@ -254,14 +254,12 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
// if no valid Bitcoin block explorer is set, select the 1st valid Bitcoin block explorer
ArrayList<BlockChainExplorer> btcExplorers = getBlockChainExplorers();
BlockChainExplorer btcExplorer = getBlockChainExplorer();
if (btcExplorer == null || btcExplorers.contains(btcExplorer) == false)
if (!blockExplorerExists(btcExplorers, getBlockChainExplorer()))
setBlockChainExplorer(btcExplorers.get(0));
// if no valid BSQ block explorer is set, randomly select a valid BSQ block explorer
ArrayList<BlockChainExplorer> bsqExplorers = getBsqBlockChainExplorers();
BlockChainExplorer bsqExplorer = getBsqBlockChainExplorer();
if (bsqExplorer == null || bsqExplorers.contains(bsqExplorer) == false)
if (!blockExplorerExists(bsqExplorers, getBsqBlockChainExplorer()))
setBsqBlockChainExplorer(bsqExplorers.get((new Random()).nextInt(bsqExplorers.size())));
tradeCurrenciesAsObservable.addAll(prefPayload.getFiatCurrencies());
@ -826,6 +824,16 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
tradeCurrenciesAsObservable.remove(change.getRemoved().get(0));
}
private boolean blockExplorerExists(ArrayList<BlockChainExplorer> explorers,
BlockChainExplorer explorer)
{
if (explorer != null && explorers != null && explorers.size() > 0)
for (int i = 0; i < explorers.size(); i++)
if (explorers.get(i).name.equals(explorer.name))
return true;
return false;
}
private interface ExcludesDelegateMethods {
void setTacAccepted(boolean tacAccepted);