Fix send Fragment to send bitcion

This commit is contained in:
hvarona 2018-11-22 00:02:30 -04:00
parent 0ebc6adfe2
commit a31efc16e4
5 changed files with 25 additions and 7 deletions

View file

@ -46,6 +46,7 @@ public abstract class GetEstimateFee {
} }
}); });
}catch(Exception e){ }catch(Exception e){
e.printStackTrace();
listener.fail(); listener.fail();
} }
} }

View file

@ -53,7 +53,7 @@ public class CrystalApplication extends Application {
public static final String BITCOIN_SERVER_URLS[] ={ public static final String BITCOIN_SERVER_URLS[] ={
"https://test-insight.bitpay.com", "https://test-insight.bitpay.com",
"https://testnet.blockexplorer.com/", //"https://testnet.blockexplorer.com/",
//"https://insight.bitpay.com/" //"https://insight.bitpay.com/"
}; };
@ -137,6 +137,11 @@ public class CrystalApplication extends Application {
resources.updateConfiguration(configuration, dm); resources.updateConfiguration(configuration, dm);
} }
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
Intent intent = new Intent(getApplicationContext(), CrystalWalletService.class); Intent intent = new Intent(getApplicationContext(), CrystalWalletService.class);
startService(intent); startService(intent);
} }

View file

@ -632,7 +632,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
public void onCarryOut() { public void onCarryOut() {
if (((ValidateBitsharesSendRequest)sendRequest).getStatus().equals(ValidateBitsharesSendRequest.StatusCode.SUCCEEDED)) { if (((ValidateBitsharesSendRequest)sendRequest).getStatus().equals(ValidateBitsharesSendRequest.StatusCode.SUCCEEDED)) {
try { try {
crystalDialog.dismiss(); // crystalDialog.dismiss();
thisFragment.dismiss(); thisFragment.dismiss();
//thisFragment.finalize(); //thisFragment.finalize();
} catch (Throwable throwable) { } catch (Throwable throwable) {
@ -664,7 +664,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
public void onCarryOut() { public void onCarryOut() {
if (((BitcoinSendRequest)sendRequest).getStatus().equals(ValidateBitsharesSendRequest.StatusCode.SUCCEEDED)) { if (((BitcoinSendRequest)sendRequest).getStatus().equals(ValidateBitsharesSendRequest.StatusCode.SUCCEEDED)) {
try { try {
crystalDialog.dismiss(); // crystalDialog.dismiss();
thisFragment.dismiss(); thisFragment.dismiss();
//thisFragment.finalize(); //thisFragment.finalize();
} catch (Throwable throwable) { } 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 * 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 @Override
public void onSuccess() { public void onSuccess() {
/* /*
* Show loading dialog * Show loading dialog
* */ * */
crystalDialog = new CrystalDialog((Activity) getContext()); /* crystalDialog = new CrystalDialog((Activity) getContext());
crystalDialog.setText("Sending"); crystalDialog.setText("Sending");
crystalDialog.progress(); crystalDialog.progress();
crystalDialog.show(); crystalDialog.show();
@ -699,7 +699,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
public void onFailed() { public void onFailed() {
} }
}); });*/
CryptoNetInfoRequests.getInstance().addRequest(sendRequest);
} }
} }

View file

@ -360,10 +360,12 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
public void send(final BitcoinSendRequest request){ public void send(final BitcoinSendRequest request){
//TODO check server connection //TODO check server connection
//TODO validate to address //TODO validate to address
System.out.println("GeneralAccountManager sending " + request.getAmount());
InsightApiGenerator.getEstimateFee(this.cryptoCoin,new ApiRequest(1, new ApiRequestListener() { InsightApiGenerator.getEstimateFee(this.cryptoCoin,new ApiRequest(1, new ApiRequestListener() {
@Override @Override
public void success(Object answer, int idPetition) { public void success(Object answer, int idPetition) {
System.out.println("GeneralAccountManager estimateFee response " + answer);
Transaction tx = new Transaction(cryptoCoin.getParameters()); Transaction tx = new Transaction(cryptoCoin.getParameters());
long currentAmount = 0; long currentAmount = 0;
long fee = -1; long fee = -1;

View file

@ -5,6 +5,8 @@ import android.widget.Spinner;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.dao.CrystalDatabase; 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.CryptoCoinBalance;
import cy.agorise.crystalwallet.models.CryptoCurrency; import cy.agorise.crystalwallet.models.CryptoCurrency;
import cy.agorise.crystalwallet.models.CryptoNetAccount; import cy.agorise.crystalwallet.models.CryptoNetAccount;
@ -29,7 +31,12 @@ public class AmountValidationField extends ValidationField {
public void validate(){ public void validate(){
try { try {
final float newAmountValue = Float.parseFloat(amountField.getText().toString()); 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 * Validation for the money
@ -66,6 +73,8 @@ public class AmountValidationField extends ValidationField {
setLastValue(""); setLastValue("");
setMessageForValue("",validator.getContext().getResources().getString(R.string.please_enter_valid_amount)); setMessageForValue("",validator.getContext().getResources().getString(R.string.please_enter_valid_amount));
setValidForValue("", false); setValidForValue("", false);
} catch (Exception e ){
e.printStackTrace();
} }
} }
} }