Added function on bitshares manager to retrieve the accounts name from the account id
This commit is contained in:
parent
1d87c9b307
commit
c2d13087e9
2 changed files with 42 additions and 0 deletions
|
@ -24,6 +24,7 @@ import cy.agorise.crystalwallet.models.seed.BIP39;
|
||||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetEquivalentRequest;
|
import cy.agorise.crystalwallet.requestmanagers.CryptoNetEquivalentRequest;
|
||||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequest;
|
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequest;
|
||||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestsListener;
|
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestsListener;
|
||||||
|
import cy.agorise.crystalwallet.requestmanagers.GetBitsharesAccountNameCacheRequest;
|
||||||
import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesLTMUpgradeRequest;
|
import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesLTMUpgradeRequest;
|
||||||
import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest;
|
import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest;
|
||||||
import cy.agorise.crystalwallet.requestmanagers.ValidateCreateBitsharesAccountRequest;
|
import cy.agorise.crystalwallet.requestmanagers.ValidateCreateBitsharesAccountRequest;
|
||||||
|
@ -231,7 +232,10 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
this.validateCreateAccount((ValidateCreateBitsharesAccountRequest) request);
|
this.validateCreateAccount((ValidateCreateBitsharesAccountRequest) request);
|
||||||
}else if (request instanceof ValidateBitsharesLTMUpgradeRequest){
|
}else if (request instanceof ValidateBitsharesLTMUpgradeRequest){
|
||||||
this.validateLTMAccountUpgrade((ValidateBitsharesLTMUpgradeRequest) request);
|
this.validateLTMAccountUpgrade((ValidateBitsharesLTMUpgradeRequest) request);
|
||||||
|
}else if (request instanceof GetBitsharesAccountNameCacheRequest){
|
||||||
|
this.getBitsharesAccountNameCacheRequest((GetBitsharesAccountNameCacheRequest) request);
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
//TODO not implemented
|
//TODO not implemented
|
||||||
System.out.println("Error request not implemented " + request.getClass().getName());
|
System.out.println("Error request not implemented " + request.getClass().getName());
|
||||||
}
|
}
|
||||||
|
@ -508,6 +512,32 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
GrapheneApiGenerator.broadcastTransaction(transaction,feeAsset, transactionRequest);
|
GrapheneApiGenerator.broadcastTransaction(transaction,feeAsset, transactionRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getBitsharesAccountNameCacheRequest(final GetBitsharesAccountNameCacheRequest request){
|
||||||
|
final CrystalDatabase db = CrystalDatabase.getAppDatabase(request.getContext());
|
||||||
|
BitsharesAccountNameCache cacheAccount = db.bitsharesAccountNameCacheDao().getByAccountId(request.getAccountId());
|
||||||
|
if(cacheAccount == null) {
|
||||||
|
this.getAccountInfoById(request.getAccountId(), new ManagerRequest() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void success(Object answer) {
|
||||||
|
GrapheneAccount userGrapheneAccount = (GrapheneAccount) answer;
|
||||||
|
BitsharesAccountNameCache cacheAccount = new BitsharesAccountNameCache();
|
||||||
|
cacheAccount.setName(userGrapheneAccount.getName());
|
||||||
|
cacheAccount.setAccountId(request.getAccountId());
|
||||||
|
db.bitsharesAccountNameCacheDao().insertBitsharesAccountNameCache(cacheAccount);
|
||||||
|
request.setAccountName(userGrapheneAccount.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fail() {
|
||||||
|
//TODO error
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
request.setAccountName(cacheAccount.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the account info from a graphene id
|
* Returns the account info from a graphene id
|
||||||
* @param grapheneId The graphene id of the account
|
* @param grapheneId The graphene id of the account
|
||||||
|
|
|
@ -12,11 +12,13 @@ public class GetBitsharesAccountNameCacheRequest extends CryptoNetInfoRequest {
|
||||||
|
|
||||||
private String accountId;
|
private String accountId;
|
||||||
private String accountName;
|
private String accountName;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
public GetBitsharesAccountNameCacheRequest(Context context, String accountId) {
|
public GetBitsharesAccountNameCacheRequest(Context context, String accountId) {
|
||||||
super(CryptoCoin.BITSHARES);
|
super(CryptoCoin.BITSHARES);
|
||||||
this.accountId = accountId;
|
this.accountId = accountId;
|
||||||
this.accountName = "";
|
this.accountName = "";
|
||||||
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccountName(String accountName){
|
public void setAccountName(String accountName){
|
||||||
|
@ -30,5 +32,15 @@ public class GetBitsharesAccountNameCacheRequest extends CryptoNetInfoRequest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Context getContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccountId() {
|
||||||
|
return accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccountName() {
|
||||||
|
return accountName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue