Merge remote-tracking branch 'hvarona/develop' into develop-local

feat_androidx_migration
hvarona 2018-11-08 00:09:38 -04:00
commit 42c48d31ea
10 changed files with 284 additions and 155 deletions

View File

@ -41,7 +41,7 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
SendTransactionValidator sendTransactionValidator;
@BindView(R.id.spFrom)
MaterialSpinner spFrom;
Spinner spFrom;
@BindView(R.id.tvFromError)
TextView tvFromError;
@BindView(R.id.etTo)

View File

@ -23,6 +23,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
@ -35,6 +36,8 @@ import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import butterknife.OnClick;
import cy.agorise.crystalwallet.enums.CryptoCoin;
import cy.agorise.crystalwallet.enums.CryptoNet;
import cy.agorise.crystalwallet.util.CircularImageView;
import cy.agorise.crystalwallet.viewmodels.CryptoNetAccountListViewModel;
import cy.agorise.crystalwallet.views.CryptoNetAccountAdapter;
@ -135,46 +138,13 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
db = CrystalDatabase.getAppDatabase(this.getContext());
this.cryptoNetAccount = db.cryptoNetAccountDao().getById(this.cryptoNetAccountId);
/*
* this is only for graphene accounts.
*
**/
this.grapheneAccount = new GrapheneAccount(this.cryptoNetAccount);
this.grapheneAccount.loadInfo(db.grapheneAccountInfoDao().getByAccountId(this.cryptoNetAccountId));
final LiveData<List<CryptoCoinBalance>> balancesList = db.cryptoCoinBalanceDao().getBalancesFromAccount(cryptoNetAccountId);
balancesList.observe(this, new Observer<List<CryptoCoinBalance>>() {
@Override
public void onChanged(@Nullable List<CryptoCoinBalance> cryptoCoinBalances) {
ArrayList<Long> assetIds = new ArrayList<Long>();
for (CryptoCoinBalance nextBalance : balancesList.getValue()) {
assetIds.add(nextBalance.getCryptoCurrencyId());
}
List<CryptoCurrency> cryptoCurrencyList = db.cryptoCurrencyDao().getByIds(assetIds);
/*
* Test
* */
CryptoCurrency crypto1 = new CryptoCurrency();
crypto1.setId(1);
crypto1.setName("BITCOIN");
crypto1.setPrecision(1);
cryptoCurrencyList.add(crypto1);
CryptoCurrencyAdapter assetAdapter = new CryptoCurrencyAdapter(getContext(), android.R.layout.simple_spinner_item, cryptoCurrencyList);
spAsset.setAdapter(assetAdapter);
}
});
receiveTransactionValidator = new ReceiveTransactionValidator(this.getContext(), this.cryptoNetAccount, spAsset, etAmount);
receiveTransactionValidator.setListener(this);
CryptoNetAccountListViewModel cryptoNetAccountListViewModel = ViewModelProviders.of(this).get(CryptoNetAccountListViewModel.class);
List<CryptoNetAccount> cryptoNetAccounts = cryptoNetAccountListViewModel.getCryptoNetAccountList();
CryptoNetAccountAdapter toSpinnerAdapter = new CryptoNetAccountAdapter(this.getContext(), android.R.layout.simple_spinner_item, cryptoNetAccounts);
spTo.setAdapter(toSpinnerAdapter);
spTo.setSelection(0);
setAccountUI();
}
builder.setView(view);
@ -247,8 +217,59 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
}
}
public void setAccountUI(){
if (this.cryptoNetAccount.getCryptoNet() == CryptoNet.BITSHARES) {
/*
* this is only for graphene accounts.
*
**/
this.grapheneAccount = new GrapheneAccount(this.cryptoNetAccount);
this.grapheneAccount.loadInfo(db.grapheneAccountInfoDao().getByAccountId(this.cryptoNetAccountId));
final LiveData<List<CryptoCoinBalance>> balancesList = db.cryptoCoinBalanceDao().getBalancesFromAccount(cryptoNetAccountId);
balancesList.observe(this, new Observer<List<CryptoCoinBalance>>() {
@Override
public void onChanged(@Nullable List<CryptoCoinBalance> cryptoCoinBalances) {
ArrayList<Long> assetIds = new ArrayList<Long>();
for (CryptoCoinBalance nextBalance : balancesList.getValue()) {
assetIds.add(nextBalance.getCryptoCurrencyId());
}
List<CryptoCurrency> cryptoCurrencyList = db.cryptoCurrencyDao().getByIds(assetIds);
/*
* Test
* */
//CryptoCurrency crypto1 = new CryptoCurrency();
//crypto1.setId(1);
//crypto1.setName("BITCOIN");
//crypto1.setPrecision(1);
//cryptoCurrencyList.add(crypto1);
CryptoCurrencyAdapter assetAdapter = new CryptoCurrencyAdapter(getContext(), android.R.layout.simple_spinner_item, cryptoCurrencyList);
spAsset.setAdapter(assetAdapter);
}
});
receiveTransactionValidator = new ReceiveTransactionValidator(this.getContext(), this.cryptoNetAccount, spAsset, etAmount);
receiveTransactionValidator.setListener(this);
} else {
CryptoCoin cryptoCoin = CryptoCoin.getByCryptoNet(this.cryptoNetAccount.getCryptoNet()).get(0);
List<String> currencyList = new ArrayList<>();
currencyList.add(cryptoCoin.getLabel());
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this.getContext(),android.R.layout.simple_list_item_1,currencyList);
spAsset.setAdapter(arrayAdapter);
receiveTransactionValidator = new ReceiveTransactionValidator(this.getContext(), this.cryptoNetAccount, spAsset, etAmount);
receiveTransactionValidator.setListener(this);
}
}
@OnItemSelected(R.id.spTo)
public void afterToSelected(Spinner spinner, int position) {
this.cryptoNetAccount = (CryptoNetAccount)spinner.getSelectedItem();
setAccountUI();
this.receiveTransactionValidator.validate();
}
@ -260,7 +281,10 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
@OnItemSelected(R.id.spAsset)
public void afterAssetSelected(Spinner spinner, int position) {
this.cryptoCurrency = (CryptoCurrency)spinner.getSelectedItem();
if (spinner.getSelectedItem() instanceof CryptoCurrency) {
this.cryptoCurrency = (CryptoCurrency) spinner.getSelectedItem();
}
this.receiveTransactionValidator.validate();
}

View File

@ -32,6 +32,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
@ -44,6 +45,8 @@ import com.google.zxing.Result;
import com.jaredrummler.materialspinner.MaterialSpinner;
import com.vincent.filepicker.ToastUtil;
import org.bitcoinj.wallet.SendRequest;
import java.io.File;
import java.math.RoundingMode;
import java.text.DecimalFormat;
@ -61,7 +64,11 @@ import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
import cy.agorise.crystalwallet.dialogs.material.CrystalDialog;
import cy.agorise.crystalwallet.dialogs.material.ToastIt;
import cy.agorise.crystalwallet.enums.CryptoCoin;
import cy.agorise.crystalwallet.enums.CryptoNet;
import cy.agorise.crystalwallet.interfaces.OnResponse;
import cy.agorise.crystalwallet.requestmanagers.BitcoinSendRequest;
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequest;
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest;
@ -90,7 +97,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
SendTransactionValidator sendTransactionValidator;
@BindView(R.id.spFrom)
MaterialSpinner spFrom;
Spinner spFrom;
@BindView(R.id.tvFromError)
TextView tvFromError;
@BindView(R.id.etTo)
@ -195,40 +202,6 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
db = CrystalDatabase.getAppDatabase(this.getContext());
this.cryptoNetAccount = db.cryptoNetAccountDao().getById(this.cryptoNetAccountId);
/*
* this is only for graphene accounts.
*
**/
this.grapheneAccount = new GrapheneAccount(this.cryptoNetAccount);
this.grapheneAccount.loadInfo(db.grapheneAccountInfoDao().getByAccountId(this.cryptoNetAccountId));
final LiveData<List<CryptoCoinBalance>> balancesList = db.cryptoCoinBalanceDao().getBalancesFromAccount(cryptoNetAccountId);
balancesList.observe(this, new Observer<List<CryptoCoinBalance>>() {
@Override
public void onChanged(@Nullable List<CryptoCoinBalance> cryptoCoinBalances) {
ArrayList<Long> assetIds = new ArrayList<Long>();
for (CryptoCoinBalance nextBalance : balancesList.getValue()) {
assetIds.add(nextBalance.getCryptoCurrencyId());
}
List<CryptoCurrency> cryptoCurrencyList = db.cryptoCurrencyDao().getByIds(assetIds);
/*
* Test
* */
/*CryptoCurrency crypto1 = new CryptoCurrency();
crypto1.setId(1);
crypto1.setName("BITCOIN");
crypto1.setPrecision(1);
cryptoCurrencyList.add(crypto1);*/
assetAdapter = new CryptoCurrencyAdapter(getContext(), android.R.layout.simple_spinner_item, cryptoCurrencyList);
spAsset.setAdapter(assetAdapter);
}
});
// TODO SendTransactionValidator to accept spFrom
sendTransactionValidator = new SendTransactionValidator(this.getContext(), this.cryptoNetAccount, spFrom, etTo, spAsset, etAmount, etMemo);
sendTransactionValidator.setListener(this);
CryptoNetAccountListViewModel cryptoNetAccountListViewModel = ViewModelProviders.of(this).get(CryptoNetAccountListViewModel.class);
List<CryptoNetAccount> cryptoNetAccounts = cryptoNetAccountListViewModel.getCryptoNetAccountList();
CryptoNetAccountAdapter fromSpinnerAdapter = new CryptoNetAccountAdapter(this.getContext(), android.R.layout.simple_spinner_item, cryptoNetAccounts);
@ -236,30 +209,31 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
/*
* If only one account block the control
* */
if(cryptoNetAccounts.size()==1){
spFrom.setEnabled(false);
}
//if(cryptoNetAccounts.size()==1){
// spFrom.setEnabled(false);
//}
spFrom.setAdapter(fromSpinnerAdapter);
//spFrom.setSelection(0);
spFrom.setSelection(0);
setAccountUI();
/*
* Custom material spinner implementation
* */
spFrom.setItems(cryptoNetAccounts);
//spFrom.setItems(cryptoNetAccounts);
//spFrom.setSelectedIndex(0);
spFrom.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<CryptoNetAccount>() {
@Override
public void onItemSelected(MaterialSpinner view, int position, long id, CryptoNetAccount item) {
sendTransactionValidator.validate();
}
});
spFrom.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() {
//spFrom.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<CryptoNetAccount>() {
// @Override
// public void onItemSelected(MaterialSpinner view, int position, long id, CryptoNetAccount item) {
// sendTransactionValidator.validate();
// }
//});
//spFrom.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() {
@Override public void onNothingSelected(MaterialSpinner spinner) {
// @Override public void onNothingSelected(MaterialSpinner spinner) {
}
});
// }
//});
// etFrom.setText(this.grapheneAccount.getName());
}
@ -305,6 +279,58 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
return builder.setView(view).create();
}
public void setAccountUI(){
if (this.cryptoNetAccount.getCryptoNet() == CryptoNet.BITSHARES) {
/*
* this is only for graphene accounts.
*
**/
this.grapheneAccount = new GrapheneAccount(this.cryptoNetAccount);
this.grapheneAccount.loadInfo(db.grapheneAccountInfoDao().getByAccountId(this.cryptoNetAccountId));
final LiveData<List<CryptoCoinBalance>> balancesList = db.cryptoCoinBalanceDao().getBalancesFromAccount(cryptoNetAccountId);
balancesList.observe(this, new Observer<List<CryptoCoinBalance>>() {
@Override
public void onChanged(@Nullable List<CryptoCoinBalance> cryptoCoinBalances) {
ArrayList<Long> assetIds = new ArrayList<Long>();
for (CryptoCoinBalance nextBalance : balancesList.getValue()) {
assetIds.add(nextBalance.getCryptoCurrencyId());
}
List<CryptoCurrency> cryptoCurrencyList = db.cryptoCurrencyDao().getByIds(assetIds);
/*
* Test
* */
//CryptoCurrency crypto1 = new CryptoCurrency();
//crypto1.setId(1);
//crypto1.setName("BITCOIN");
//crypto1.setPrecision(1);
//cryptoCurrencyList.add(crypto1);
CryptoCurrencyAdapter assetAdapter = new CryptoCurrencyAdapter(getContext(), android.R.layout.simple_spinner_item, cryptoCurrencyList);
spAsset.setAdapter(assetAdapter);
}
});
// TODO SendTransactionValidator to accept spFrom
sendTransactionValidator = new SendTransactionValidator(this.getContext(), this.cryptoNetAccount, spFrom, etTo, spAsset, etAmount, etMemo);
sendTransactionValidator.setListener(this);
} else {
CryptoCoin cryptoCoin = CryptoCoin.getByCryptoNet(this.cryptoNetAccount.getCryptoNet()).get(0);
List<String> currencyList = new ArrayList<>();
currencyList.add(cryptoCoin.getLabel());
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this.getContext(),android.R.layout.simple_list_item_1,currencyList);
spAsset.setAdapter(arrayAdapter);
// TODO SendTransactionValidator to accept spFrom
sendTransactionValidator = new SendTransactionValidator(this.getContext(), this.cryptoNetAccount, spFrom, etTo, spAsset, etAmount, etMemo);
sendTransactionValidator.setListener(this);
}
}
private void requestPermission() {
@ -430,10 +456,12 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
}
}
/*@OnItemSelected(R.id.spFrom)
@OnItemSelected(R.id.spFrom)
public void afterFromSelected(Spinner spinner, int position) {
this.cryptoNetAccount = (CryptoNetAccount)spinner.getSelectedItem();
setAccountUI();
this.sendTransactionValidator.validate();
}*/
}
@OnTextChanged(value = R.id.etTo,
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
@ -576,49 +604,85 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
@OnClick(R.id.btnSend)
public void sendTransaction(){
final SendTransactionFragment thisFragment = this;
final CryptoNetInfoRequest sendRequest;
if (this.sendTransactionValidator.isValid()) {
CryptoNetAccount fromAccountSelected = (CryptoNetAccount) spFrom.getItems().get(spFrom.getSelectedIndex());
//CryptoNetAccount fromAccountSelected = (CryptoNetAccount) spFrom.getItems().get(spFrom.getSelectedIndex());
CryptoNetAccount fromAccountSelected = (CryptoNetAccount) spFrom.getSelectedItem();
/*
* this is only for graphene accounts.
*
**/
GrapheneAccount grapheneAccountSelected = new GrapheneAccount(fromAccountSelected);
grapheneAccountSelected.loadInfo(db.grapheneAccountInfoDao().getByAccountId(fromAccountSelected.getId()));
if (fromAccountSelected.getCryptoNet() == CryptoNet.BITSHARES) {
/*
* this is only for graphene accounts.
*
**/
GrapheneAccount grapheneAccountSelected = new GrapheneAccount(fromAccountSelected);
grapheneAccountSelected.loadInfo(db.grapheneAccountInfoDao().getByAccountId(fromAccountSelected.getId()));
//TODO convert the amount to long type using the precision of the currency
Double amountFromEditText = Double.parseDouble(this.etAmount.getText().toString());
Long amount = (long) Math.floor(amountFromEditText * Math.round(Math.pow(10, ((CryptoCurrency) spAsset.getSelectedItem()).getPrecision())));
//TODO convert the amount to long type using the precision of the currency
Double amountFromEditText = Double.parseDouble(this.etAmount.getText().toString());
Long amount = (long)Math.floor(amountFromEditText*Math.round(Math.pow(10,((CryptoCurrency)spAsset.getSelectedItem()).getPrecision())));
/*final ValidateBitsharesSendRequest*/
sendRequest = new ValidateBitsharesSendRequest(
this.getContext(),
grapheneAccountSelected,
this.etTo.getText().toString(),
amount,
((CryptoCurrency) spAsset.getSelectedItem()).getName(),
etMemo.getText().toString()
);
final ValidateBitsharesSendRequest sendRequest = new ValidateBitsharesSendRequest(
this.getContext(),
grapheneAccountSelected,
this.etTo.getText().toString(),
amount,
((CryptoCurrency)spAsset.getSelectedItem()).getName(),
etMemo.getText().toString()
);
sendRequest.setListener(new CryptoNetInfoRequestListener() {
@Override
public void onCarryOut() {
if (sendRequest.getStatus().equals(ValidateBitsharesSendRequest.StatusCode.SUCCEEDED)){
try {
crystalDialog.dismiss();
thisFragment.dismiss();
//thisFragment.finalize();
} catch (Throwable throwable) {
throwable.printStackTrace();
sendRequest.setListener(new CryptoNetInfoRequestListener() {
@Override
public void onCarryOut() {
if (((ValidateBitsharesSendRequest)sendRequest).getStatus().equals(ValidateBitsharesSendRequest.StatusCode.SUCCEEDED)) {
try {
crystalDialog.dismiss();
thisFragment.dismiss();
//thisFragment.finalize();
} catch (Throwable throwable) {
throwable.printStackTrace();
}
} else {
Toast.makeText(getContext(), getContext().getString(R.string.unable_to_send_amount), Toast.LENGTH_LONG);
}
} else {
Toast.makeText(getContext(), getContext().getString(R.string.unable_to_send_amount), Toast.LENGTH_LONG);
}
}
});
});
} else {
CryptoCoin cryptoCoin = CryptoCoin.getByCryptoNet(this.cryptoNetAccount.getCryptoNet()).get(0);
//TODO convert the amount to long type using the precision of the currency
Double amountFromEditText = Double.parseDouble(this.etAmount.getText().toString());
Long amount = (long) Math.floor(amountFromEditText * (Math.pow(10, cryptoCoin.getPrecision())));
sendRequest = new BitcoinSendRequest(
this.getContext(),
this.cryptoNetAccount,
this.etTo.getText().toString(),
amount,
cryptoCoin,
etMemo.getText().toString()
);
sendRequest.setListener(new CryptoNetInfoRequestListener() {
@Override
public void onCarryOut() {
if (((BitcoinSendRequest)sendRequest).getStatus().equals(ValidateBitsharesSendRequest.StatusCode.SUCCEEDED)) {
try {
crystalDialog.dismiss();
thisFragment.dismiss();
//thisFragment.finalize();
} catch (Throwable throwable) {
throwable.printStackTrace();
}
} else {
Toast.makeText(getContext(), getContext().getString(R.string.unable_to_send_amount), Toast.LENGTH_LONG);
}
}
});
}
/*
* If exists mode scurity show it and valide events in case of success or fail

View File

@ -22,7 +22,7 @@ public class SendTransactionValidator extends UIValidator {
private CryptoNetAccount account;
public SendTransactionValidator(Context context, CryptoNetAccount account, MaterialSpinner fromEdit, EditText toEdit, Spinner assetSpinner, EditText amountEdit, EditText memoEdit){
public SendTransactionValidator(Context context, CryptoNetAccount account, Spinner fromEdit, EditText toEdit, Spinner assetSpinner, EditText amountEdit, EditText memoEdit){
super(context);
this.account = account;
this.addField(new FromValidationField(fromEdit));

View File

@ -18,16 +18,22 @@ public class AssetValidationField extends ValidationField {
}
public void validate(){
final CryptoCurrency cryptoCurrencySelected = (CryptoCurrency) this.assetField.getSelectedItem();
if (cryptoCurrencySelected != null) {
final String newValue = "" + cryptoCurrencySelected.getId();
if (this.assetField.getSelectedItem() instanceof CryptoCurrency) {
final CryptoCurrency cryptoCurrencySelected = (CryptoCurrency) this.assetField.getSelectedItem();
if (cryptoCurrencySelected != null) {
final String newValue = "" + cryptoCurrencySelected.getId();
this.setLastValue(newValue);
setValidForValue(newValue, true);
} else {
final String newValue = "" + -1;
setMessageForValue(newValue, "Select a currency");
this.setLastValue(newValue);
setValidForValue(newValue, false);
}
} else {
final String newValue = "" + -1;
this.setLastValue(newValue);
setValidForValue(newValue, true);
} else {
final String newValue = ""+-1;
setMessageForValue(newValue,"Select a currency");
this.setLastValue(newValue);
setValidForValue(newValue, false);
}
}
}

View File

@ -17,9 +17,9 @@ import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountReq
public class FromValidationField extends ValidationField {
//private EditText fromField;
private MaterialSpinner fromField;
private Spinner fromField;
public FromValidationField(MaterialSpinner fromField){
public FromValidationField(Spinner fromField){
super(fromField);
this.fromField = fromField;
}
@ -27,8 +27,8 @@ public class FromValidationField extends ValidationField {
public void validate(){
final String newValue;
if (fromField.getSelectedIndex() != -1) {
final CryptoNetAccount cryptoNetAccount = (CryptoNetAccount) fromField.getItems().get(fromField.getSelectedIndex());
if (fromField.getSelectedItem() instanceof CryptoNetAccount){
final CryptoNetAccount cryptoNetAccount = (CryptoNetAccount) fromField.getSelectedItem();
newValue = cryptoNetAccount.getName();
} else {
newValue = "";

View File

@ -6,6 +6,7 @@ import android.widget.Spinner;
import com.jaredrummler.materialspinner.MaterialSpinner;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.enums.CryptoNet;
import cy.agorise.crystalwallet.models.CryptoNetAccount;
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
@ -17,10 +18,10 @@ import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountReq
public class ToValidationField extends ValidationField {
private MaterialSpinner fromField;
private Spinner fromField;
private EditText toField;
public ToValidationField(MaterialSpinner fromField, EditText toField){
public ToValidationField(Spinner fromField, EditText toField){
super(toField);
this.fromField = fromField;
this.toField = toField;
@ -28,8 +29,9 @@ public class ToValidationField extends ValidationField {
public void validate(){
final String fromNewValue;
if (fromField.getSelectedIndex() != -1) {
final CryptoNetAccount cryptoNetAccount = (CryptoNetAccount) fromField.getItems().get(fromField.getSelectedIndex());
CryptoNetAccount cryptoNetAccount = null;
if (fromField.getSelectedItem() instanceof CryptoNetAccount){
cryptoNetAccount = (CryptoNetAccount) fromField.getSelectedItem();
fromNewValue = cryptoNetAccount.getName();
} else {
fromNewValue = "";
@ -45,19 +47,30 @@ public class ToValidationField extends ValidationField {
setValidForValue(mixedValue, false);
} else {
final ValidateExistBitsharesAccountRequest request = new ValidateExistBitsharesAccountRequest(toNewValue);
request.setListener(new CryptoNetInfoRequestListener() {
@Override
public void onCarryOut() {
if (!request.getAccountExists()) {
setMessageForValue(mixedValue, validator.getContext().getResources().getString(R.string.account_name_not_exist,"'"+toNewValue+"'"));
setValidForValue(mixedValue, false);
} else {
if (cryptoNetAccount != null) {
if (cryptoNetAccount.getCryptoNet() == CryptoNet.BITSHARES) {
final ValidateExistBitsharesAccountRequest request = new ValidateExistBitsharesAccountRequest(toNewValue);
request.setListener(new CryptoNetInfoRequestListener() {
@Override
public void onCarryOut() {
if (!request.getAccountExists()) {
setMessageForValue(mixedValue, validator.getContext().getResources().getString(R.string.account_name_not_exist, "'" + toNewValue + "'"));
setValidForValue(mixedValue, false);
} else {
setValidForValue(mixedValue, true);
}
}
});
CryptoNetInfoRequests.getInstance().addRequest(request);
} else {
//if (addressIsValid(toNewValue)) {
setValidForValue(mixedValue, true);
}
//} else {
// setMessageForValue(mixedValue, "Is not a valid address");
// setValidForValue(mixedValue, false);
//}
}
});
CryptoNetInfoRequests.getInstance().addRequest(request);
}
}
}
}

View File

@ -6,6 +6,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
@ -42,9 +43,11 @@ public class CryptoNetAccountAdapter extends ArrayAdapter<CryptoNetAccount> {
LayoutInflater inflater = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.crypto_net_account_adapter_item, parent, false);
TextView tvCryptoNetAccountName = v.findViewById(R.id.tvCryptoNetAccountName);
ImageView ivCryptoNetIcon = v.findViewById(R.id.ivCryptoNetIcon);
CryptoNetAccount cryptoNetAccount = getItem(position);
tvCryptoNetAccountName.setText(cryptoNetAccount.getName());
ivCryptoNetIcon.setImageResource(cryptoNetAccount.getCryptoNet().getIconImageResource());
return v;
}

View File

@ -8,9 +8,27 @@
android:paddingRight="10dp"
android:paddingTop="10dp">
<TextView
android:id="@+id/tvCryptoNetAccountName"
android:layout_width="wrap_content"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<ImageView
android:id="@+id/ivCryptoNetIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:maxHeight="28dp"
android:maxWidth="28dp"
app:srcCompat="@drawable/bts" />
<TextView
android:id="@+id/tvCryptoNetAccountName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@id/ivCryptoNetIcon"
android:ems="10"
android:text="unknown coin" />
</RelativeLayout>
</LinearLayout>

View File

@ -46,7 +46,8 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.jaredrummler.materialspinner.MaterialSpinner
<!--<com.jaredrummler.materialspinner.MaterialSpinner-->
<Spinner
android:id="@+id/spFrom"
android:layout_width="0dp"
android:layout_height="40dp"