Fix send Fragment to send bitcion

feat_androidx_migration
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){
e.printStackTrace();
listener.fail();
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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();
}
}
}