From e5bbce9fcdbc26cdff1afa0032c076c285783978 Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 23 Apr 2018 21:13:48 -0400 Subject: [PATCH] Remove the search for the equivalence of the same asset --- .../apigenerator/GrapheneApiGenerator.java | 9 ++++++++- .../ValidateImportBitsharesAccountRequest.java | 2 +- .../crystalwallet/service/EquivalencesThread.java | 10 +++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java index 6edebed..3312030 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java @@ -589,7 +589,14 @@ public abstract class GrapheneApiGenerator { } } - public static void getEquivalenValue(String baseAssetName, final List quoteAssets, final Context context){ + /** + * Retrieves the equivalent value from a list of assets to a base asset + * + * @param baseAssetName The base asset to use + * @param quoteAssets The list of quotes assets to query + * @param context The Context of this Application + */ + public static void getEquivalentValue(String baseAssetName, final List quoteAssets, final Context context){ CrystalDatabase db = CrystalDatabase.getAppDatabase(context); final CryptoCurrencyDao cryptoCurrencyDao = db.cryptoCurrencyDao(); final BitsharesAssetDao bitsharesAssetDao = db.bitsharesAssetDao(); diff --git a/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ValidateImportBitsharesAccountRequest.java b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ValidateImportBitsharesAccountRequest.java index 19b449b..81c3aa4 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ValidateImportBitsharesAccountRequest.java +++ b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ValidateImportBitsharesAccountRequest.java @@ -4,7 +4,7 @@ import cy.agorise.crystalwallet.enums.CryptoCoin; import cy.agorise.crystalwallet.enums.SeedType; /** - * Imports a bitsahres accounts, + * Imports a bitshares accounts, * * return true if the account exist, and the mnemonic (brainkey provide is for that account * Created by Henry Varona on 1/10/2017. diff --git a/app/src/main/java/cy/agorise/crystalwallet/service/EquivalencesThread.java b/app/src/main/java/cy/agorise/crystalwallet/service/EquivalencesThread.java index 263a0cf..12a446c 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/service/EquivalencesThread.java +++ b/app/src/main/java/cy/agorise/crystalwallet/service/EquivalencesThread.java @@ -3,6 +3,7 @@ package cy.agorise.crystalwallet.service; import android.arch.lifecycle.LifecycleService; import android.util.Log; +import java.util.ArrayList; import java.util.List; import cy.agorise.crystalwallet.apigenerator.GrapheneApiGenerator; @@ -29,8 +30,15 @@ public class EquivalencesThread extends Thread{ super.run(); while(this.keepLoadingEquivalences){ + List queryAsset = new ArrayList<>(); + for(BitsharesAsset asset : bitsharesAssets){ + if(!asset.getName().equals(fromAsset)){ + queryAsset.add(asset); + } + } try { - GrapheneApiGenerator.getEquivalenValue(fromAsset, bitsharesAssets, this.service); + //GrapheneApiGenerator.getEquivalentValue(fromAsset, bitsharesAssets, this.service); + GrapheneApiGenerator.getEquivalentValue(fromAsset, queryAsset, this.service); Log.i("Equivalences Thread", "In loop"); Thread.sleep(300000); } catch (InterruptedException e) {