- Fixed ui info request when account name changes
This commit is contained in:
parent
e466fc8d53
commit
e9e8c11eb3
4 changed files with 20 additions and 21 deletions
|
@ -9,6 +9,7 @@ import android.text.Editable;
|
|||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -61,7 +62,7 @@ public class ImportSeedActivity extends AppCompatActivity implements ImportSeedV
|
|||
@OnTextChanged(value = R.id.etAccountName,
|
||||
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
||||
void afterAccountNameChanged(Editable editable) {
|
||||
this.importSeedValidator.validateAccountName(editable.toString());
|
||||
this.importSeedValidator.validateAccountName(editable.toString(), etSeedWords.getText().toString());
|
||||
}
|
||||
|
||||
@OnClick(R.id.btnImport)
|
||||
|
@ -88,5 +89,7 @@ public class ImportSeedActivity extends AppCompatActivity implements ImportSeedV
|
|||
@Override
|
||||
public void onValidationFailed(String error) {
|
||||
//Show errors
|
||||
Toast.makeText(this, error,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public abstract class CryptoNetInfoRequest {
|
|||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void _fireOnCarryOutEvent(){
|
||||
protected void _fireOnCarryOutEvent(){
|
||||
listener.onCarryOut();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,19 +49,17 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
|||
for(PublicKey activeKey : prop.active.getKeyAuthList()){
|
||||
if(activeKey.toBytes().equals(bk.getPublicKey())){
|
||||
importRequest.setMnemonicIsCorrect(true);
|
||||
importRequest._fireOnCarryOutEvent();
|
||||
return;
|
||||
}
|
||||
}
|
||||
importRequest.setMnemonicIsCorrect(false);
|
||||
importRequest._fireOnCarryOutEvent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(int idPetition) {
|
||||
importRequest._fireOnCarryOutEvent();
|
||||
//
|
||||
}
|
||||
});
|
||||
GrapheneApiGenerator.getAccountById((String)answer,getAccountInfo);
|
||||
|
@ -69,7 +67,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
|||
|
||||
@Override
|
||||
public void fail(int idPetition) {
|
||||
importRequest._fireOnCarryOutEvent();
|
||||
//
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -63,24 +63,22 @@ public class ImportSeedValidator {
|
|||
|
||||
//}
|
||||
|
||||
public void validateAccountName(final String accountName){
|
||||
public void validateAccountName(final String accountName, final String mnemonic){
|
||||
final ValidationField validationField = getValidationField("accountname");
|
||||
validationField.setLastValue(accountName);
|
||||
|
||||
if (this.accountSeed != null){
|
||||
final ValidateImportBitsharesAccountRequest request = new ValidateImportBitsharesAccountRequest(this.accountSeed.getName(),this.accountSeed.getMasterSeed());
|
||||
request.setListener(new CryptoNetInfoRequestListener() {
|
||||
@Override
|
||||
public void onCarryOut() {
|
||||
if (!request.getAccountExists()){
|
||||
validationField.setValidForValue(accountName, false);
|
||||
validationField.setMessage(res.getString(R.string.account_name_not_exist));
|
||||
} else {
|
||||
validationField.setValidForValue(accountName, true);
|
||||
}
|
||||
final ValidateImportBitsharesAccountRequest request = new ValidateImportBitsharesAccountRequest(accountName,mnemonic);
|
||||
request.setListener(new CryptoNetInfoRequestListener() {
|
||||
@Override
|
||||
public void onCarryOut() {
|
||||
if (!request.getAccountExists()){
|
||||
validationField.setValidForValue(accountName, false);
|
||||
validationField.setMessage(res.getString(R.string.account_name_not_exist));
|
||||
} else {
|
||||
validationField.setValidForValue(accountName, true);
|
||||
}
|
||||
});
|
||||
CryptoNetInfoRequests.getInstance().addRequest(request);
|
||||
}
|
||||
}
|
||||
});
|
||||
CryptoNetInfoRequests.getInstance().addRequest(request);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue