- Added CryptoNetInfoRequests for specific information retrieval from the api servers

This commit is contained in:
Javier Varona 2017-10-01 21:50:12 -04:00
parent dff2dae254
commit dff4b6f931
6 changed files with 136 additions and 0 deletions

View file

@ -57,6 +57,7 @@ public class ImportSeedActivity extends AppCompatActivity {
//TODO verify if PIN and PIN confirmation are not null and are the same
//TODO verify if words are already in the db
//TODO check if name has been asigned to other seed
seed.setMasterSeed(etSeedWords.getText().toString());
seed.setName(etAccountName.getText().toString());

View file

@ -0,0 +1,24 @@
package cy.agorise.crystalwallet.cryptonetinforequests;
import cy.agorise.crystalwallet.enums.CryptoCoin;
/**
* Created by Henry Varona on 1/10/2017.
*/
abstract class CryptoNetInfoRequest {
protected CryptoCoin coin;
protected CryptoNetInfoRequestListener listener;
public CryptoNetInfoRequest(CryptoCoin coin){
this.coin = coin;
}
public void setListener(CryptoNetInfoRequestListener listener){
this.listener = listener;
}
public void _fireOnCarryOutEvent(){
listener.onCarryOut();
}
}

View file

@ -0,0 +1,10 @@
package cy.agorise.crystalwallet.cryptonetinforequests;
/**
* Created by Henry Varona on 1/10/2017.
*/
interface CryptoNetInfoRequestListener {
public void onCarryOut();
}

View file

@ -0,0 +1,48 @@
package cy.agorise.crystalwallet.cryptonetinforequests;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Henry Varona on 1/10/2017.
*/
public class CryptoNetInfoRequests {
private List<CryptoNetInfoRequest> requests;
private List<CryptoNetInfoRequestsListener> listeners;
private CryptoNetInfoRequests instance;
private void CryptoNetInfoRequests(){
//Private constructor for singleton pattern
}
public CryptoNetInfoRequests getInstance(){
if (this.instance == null){
this.instance = new CryptoNetInfoRequests();
this.requests = new ArrayList<CryptoNetInfoRequest>();
this.listeners = new ArrayList<CryptoNetInfoRequestsListener>();
}
return this.instance;
}
public void addRequest(CryptoNetInfoRequest request){
this.requests.add(request);
this._fireNewRequestEvent(request);
}
public void removeRequest(CryptoNetInfoRequest request){
this.requests.remove(request);
}
public void addListener(CryptoNetInfoRequestsListener listener){
this.listeners.add(listener);
}
private void _fireNewRequestEvent(CryptoNetInfoRequest request){
for (int i=0;i<this.listeners.size();i++){
this.listeners.get(i).onNewRequest(request);
}
}
}

View file

@ -0,0 +1,9 @@
package cy.agorise.crystalwallet.cryptonetinforequests;
/**
* Created by Henry Varona on 1/10/2017.
*/
interface CryptoNetInfoRequestsListener {
public void onNewRequest(CryptoNetInfoRequest request);
}

View file

@ -0,0 +1,44 @@
package cy.agorise.crystalwallet.cryptonetinforequests;
import cy.agorise.crystalwallet.enums.CryptoCoin;
/**
* Created by Henry Varona on 1/10/2017.
*/
class ValidateImportBitsharesAccountRequest extends CryptoNetInfoRequest {
private String accountName;
private String mnemonic;
private Boolean accountExists;
private Boolean mnemonicIsCorrect;
public ValidateImportBitsharesAccountRequest(String accountName, String mnemonic){
super(CryptoCoin.BITSHARES);
this.accountName = accountName;
this.mnemonic = mnemonic;
}
public void setAccountExists(boolean value){
this.accountExists = value;
}
public void setMnemonicIsCorrect(boolean value){
this.mnemonicIsCorrect = value;
}
public boolean getAccountExists(){
return this.accountExists;
}
public boolean getMnemonicIsCorrect(){
return this.mnemonicIsCorrect;
}
public void validate(){
if ((this.accountExists != null) && (this.mnemonicIsCorrect != null)){
this._fireOnCarryOutEvent();
}
}
}