- Fixed ui info request when account name changes

This commit is contained in:
Javier Varona 2017-10-04 20:54:24 -04:00
parent e466fc8d53
commit e9e8c11eb3
4 changed files with 20 additions and 21 deletions

View file

@ -9,6 +9,7 @@ import android.text.Editable;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import java.util.List; import java.util.List;
@ -61,7 +62,7 @@ public class ImportSeedActivity extends AppCompatActivity implements ImportSeedV
@OnTextChanged(value = R.id.etAccountName, @OnTextChanged(value = R.id.etAccountName,
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
void afterAccountNameChanged(Editable editable) { void afterAccountNameChanged(Editable editable) {
this.importSeedValidator.validateAccountName(editable.toString()); this.importSeedValidator.validateAccountName(editable.toString(), etSeedWords.getText().toString());
} }
@OnClick(R.id.btnImport) @OnClick(R.id.btnImport)
@ -88,5 +89,7 @@ public class ImportSeedActivity extends AppCompatActivity implements ImportSeedV
@Override @Override
public void onValidationFailed(String error) { public void onValidationFailed(String error) {
//Show errors //Show errors
Toast.makeText(this, error,
Toast.LENGTH_LONG).show();
} }
} }

View file

@ -18,7 +18,7 @@ public abstract class CryptoNetInfoRequest {
this.listener = listener; this.listener = listener;
} }
public void _fireOnCarryOutEvent(){ protected void _fireOnCarryOutEvent(){
listener.onCarryOut(); listener.onCarryOut();
} }
} }

View file

@ -49,19 +49,17 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
for(PublicKey activeKey : prop.active.getKeyAuthList()){ for(PublicKey activeKey : prop.active.getKeyAuthList()){
if(activeKey.toBytes().equals(bk.getPublicKey())){ if(activeKey.toBytes().equals(bk.getPublicKey())){
importRequest.setMnemonicIsCorrect(true); importRequest.setMnemonicIsCorrect(true);
importRequest._fireOnCarryOutEvent();
return; return;
} }
} }
importRequest.setMnemonicIsCorrect(false); importRequest.setMnemonicIsCorrect(false);
importRequest._fireOnCarryOutEvent();
} }
} }
@Override @Override
public void fail(int idPetition) { public void fail(int idPetition) {
importRequest._fireOnCarryOutEvent(); //
} }
}); });
GrapheneApiGenerator.getAccountById((String)answer,getAccountInfo); GrapheneApiGenerator.getAccountById((String)answer,getAccountInfo);
@ -69,7 +67,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
@Override @Override
public void fail(int idPetition) { public void fail(int idPetition) {
importRequest._fireOnCarryOutEvent(); //
} }
}); });

View file

@ -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"); final ValidationField validationField = getValidationField("accountname");
validationField.setLastValue(accountName); validationField.setLastValue(accountName);
if (this.accountSeed != null){ final ValidateImportBitsharesAccountRequest request = new ValidateImportBitsharesAccountRequest(accountName,mnemonic);
final ValidateImportBitsharesAccountRequest request = new ValidateImportBitsharesAccountRequest(this.accountSeed.getName(),this.accountSeed.getMasterSeed()); request.setListener(new CryptoNetInfoRequestListener() {
request.setListener(new CryptoNetInfoRequestListener() { @Override
@Override public void onCarryOut() {
public void onCarryOut() { if (!request.getAccountExists()){
if (!request.getAccountExists()){ validationField.setValidForValue(accountName, false);
validationField.setValidForValue(accountName, false); validationField.setMessage(res.getString(R.string.account_name_not_exist));
validationField.setMessage(res.getString(R.string.account_name_not_exist)); } else {
} else { validationField.setValidForValue(accountName, true);
validationField.setValidForValue(accountName, true);
}
} }
}); }
CryptoNetInfoRequests.getInstance().addRequest(request); });
} CryptoNetInfoRequests.getInstance().addRequest(request);
} }
} }