From a31efc16e4a8bc21992e825ad305713553bdc62b Mon Sep 17 00:00:00 2001 From: hvarona Date: Thu, 22 Nov 2018 00:02:30 -0400 Subject: [PATCH] Fix send Fragment to send bitcion --- .../apigenerator/insightapi/GetEstimateFee.java | 1 + .../crystalwallet/application/CrystalApplication.java | 7 ++++++- .../fragments/SendTransactionFragment.java | 11 ++++++----- .../crystalwallet/manager/GeneralAccountManager.java | 2 ++ .../validationfields/AmountValidationField.java | 11 ++++++++++- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetEstimateFee.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetEstimateFee.java index dccb4dd..9746530 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetEstimateFee.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/insightapi/GetEstimateFee.java @@ -46,6 +46,7 @@ public abstract class GetEstimateFee { } }); }catch(Exception e){ + e.printStackTrace(); listener.fail(); } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java index f0c3f29..4a96646 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java +++ b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java @@ -53,7 +53,7 @@ public class CrystalApplication extends Application { public static final String BITCOIN_SERVER_URLS[] ={ "https://test-insight.bitpay.com", - "https://testnet.blockexplorer.com/", + //"https://testnet.blockexplorer.com/", //"https://insight.bitpay.com/" }; @@ -137,6 +137,11 @@ public class CrystalApplication extends Application { resources.updateConfiguration(configuration, dm); } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + Intent intent = new Intent(getApplicationContext(), CrystalWalletService.class); startService(intent); } diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java index bad0583..bc7805a 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java @@ -632,7 +632,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat public void onCarryOut() { if (((ValidateBitsharesSendRequest)sendRequest).getStatus().equals(ValidateBitsharesSendRequest.StatusCode.SUCCEEDED)) { try { - crystalDialog.dismiss(); +// crystalDialog.dismiss(); thisFragment.dismiss(); //thisFragment.finalize(); } catch (Throwable throwable) { @@ -664,7 +664,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat public void onCarryOut() { if (((BitcoinSendRequest)sendRequest).getStatus().equals(ValidateBitsharesSendRequest.StatusCode.SUCCEEDED)) { try { - crystalDialog.dismiss(); +// crystalDialog.dismiss(); thisFragment.dismiss(); //thisFragment.finalize(); } catch (Throwable throwable) { @@ -680,14 +680,14 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat /* * If exists mode scurity show it and valide events in case of success or fail * */ - CrystalSecurityMonitor.getInstance(this.getActivity()).callPasswordRequest(this.getActivity(), new OnResponse() { +/* CrystalSecurityMonitor.getInstance(this.getActivity()).callPasswordRequest(this.getActivity(), new OnResponse() { @Override public void onSuccess() { /* * Show loading dialog * */ - crystalDialog = new CrystalDialog((Activity) getContext()); +/* crystalDialog = new CrystalDialog((Activity) getContext()); crystalDialog.setText("Sending"); crystalDialog.progress(); crystalDialog.show(); @@ -699,7 +699,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat public void onFailed() { } - }); + });*/ + CryptoNetInfoRequests.getInstance().addRequest(sendRequest); } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/manager/GeneralAccountManager.java b/app/src/main/java/cy/agorise/crystalwallet/manager/GeneralAccountManager.java index 17fc1d8..84c8165 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/manager/GeneralAccountManager.java +++ b/app/src/main/java/cy/agorise/crystalwallet/manager/GeneralAccountManager.java @@ -360,10 +360,12 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf public void send(final BitcoinSendRequest request){ //TODO check server connection //TODO validate to address + System.out.println("GeneralAccountManager sending " + request.getAmount()); InsightApiGenerator.getEstimateFee(this.cryptoCoin,new ApiRequest(1, new ApiRequestListener() { @Override public void success(Object answer, int idPetition) { + System.out.println("GeneralAccountManager estimateFee response " + answer); Transaction tx = new Transaction(cryptoCoin.getParameters()); long currentAmount = 0; long fee = -1; diff --git a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/AmountValidationField.java b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/AmountValidationField.java index a01f1a8..f18592f 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/AmountValidationField.java +++ b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/AmountValidationField.java @@ -5,6 +5,8 @@ import android.widget.Spinner; import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.dao.CrystalDatabase; +import cy.agorise.crystalwallet.enums.CryptoCoin; +import cy.agorise.crystalwallet.enums.CryptoNet; import cy.agorise.crystalwallet.models.CryptoCoinBalance; import cy.agorise.crystalwallet.models.CryptoCurrency; import cy.agorise.crystalwallet.models.CryptoNetAccount; @@ -29,7 +31,12 @@ public class AmountValidationField extends ValidationField { public void validate(){ try { final float newAmountValue = Float.parseFloat(amountField.getText().toString()); - final CryptoCurrency cryptoCurrency = (CryptoCurrency)assetSpinner.getSelectedItem(); + final CryptoCurrency cryptoCurrency; + if(this.account.getCryptoNet() == CryptoNet.BITSHARES) { + cryptoCurrency = (CryptoCurrency) assetSpinner.getSelectedItem(); + }else{ + cryptoCurrency = CrystalDatabase.getAppDatabase(amountField.getContext()).cryptoCurrencyDao().getByNameAndCryptoNet(CryptoCoin.getByCryptoNet(this.account.getCryptoNet()).get(0).getLabel(),this.account.getCryptoNet().name()); + } /* * Validation for the money @@ -66,6 +73,8 @@ public class AmountValidationField extends ValidationField { setLastValue(""); setMessageForValue("",validator.getContext().getResources().getString(R.string.please_enter_valid_amount)); setValidForValue("", false); + } catch (Exception e ){ + e.printStackTrace(); } } }