- Added function to Crystal Service to get the bitshares account names of the transaction's accounts id
This commit is contained in:
parent
cea9e8faeb
commit
a5dcf393bf
3 changed files with 70 additions and 10 deletions
|
@ -27,6 +27,11 @@ public interface BitsharesAccountNameCacheDao {
|
|||
@Query("SELECT * FROM bitshares_account_name_cache WHERE name = :account_name")
|
||||
BitsharesAccountNameCache getByAccountName(String account_name);
|
||||
|
||||
@Query("SELECT -1 AS id, cct.'to' AS account_id, '' AS name FROM crypto_coin_transaction AS cct WHERE cct.'to' NOT IN (SELECT account_id FROM bitshares_account_name_cache banc)" +
|
||||
" UNION " +
|
||||
"SELECT -1 AS id, cct.'from' AS account_id, '' AS name FROM crypto_coin_transaction AS cct WHERE cct.'from' NOT IN (SELECT account_id FROM bitshares_account_name_cache banc)")
|
||||
LiveData<List<BitsharesAccountNameCache>> getUncachedBitsharesAccountName();
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
public long[] insertBitsharesAccountNameCache(BitsharesAccountNameCache... accountsNames);
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package cy.agorise.crystalwallet.requestmanagers;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import cy.agorise.crystalwallet.enums.CryptoCoin;
|
||||
|
||||
/**
|
||||
* Created by henry on 6/20/2018.
|
||||
*/
|
||||
|
||||
public class GetBitsharesAccountNameCacheRequest extends CryptoNetInfoRequest {
|
||||
|
||||
private String accountId;
|
||||
private String accountName;
|
||||
|
||||
public GetBitsharesAccountNameCacheRequest(Context context, String accountId) {
|
||||
super(CryptoCoin.BITSHARES);
|
||||
this.accountId = accountId;
|
||||
this.accountName = "";
|
||||
}
|
||||
|
||||
public void setAccountName(String accountName){
|
||||
this.accountName = accountName;
|
||||
this.validate();
|
||||
}
|
||||
|
||||
public void validate(){
|
||||
if ((!this.accountName.equals(""))){
|
||||
this._fireOnCarryOutEvent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -15,7 +15,9 @@ import android.util.Log;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cy.agorise.crystalwallet.apigenerator.GrapheneApiGenerator;
|
||||
import cy.agorise.crystalwallet.manager.FileBackupManager;
|
||||
import cy.agorise.crystalwallet.models.BitsharesAccountNameCache;
|
||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||
import cy.agorise.crystalwallet.enums.CryptoNet;
|
||||
|
@ -29,6 +31,7 @@ import cy.agorise.crystalwallet.models.GrapheneAccount;
|
|||
import cy.agorise.crystalwallet.models.GrapheneAccountInfo;
|
||||
import cy.agorise.crystalwallet.requestmanagers.FileServiceRequest;
|
||||
import cy.agorise.crystalwallet.requestmanagers.FileServiceRequests;
|
||||
import cy.agorise.crystalwallet.requestmanagers.GetBitsharesAccountNameCacheRequest;
|
||||
|
||||
/**
|
||||
* Created by Henry Varona on 3/10/2017.
|
||||
|
@ -41,6 +44,7 @@ public class CrystalWalletService extends LifecycleService {
|
|||
private ServiceHandler mServiceHandler;
|
||||
private BitsharesAccountManager bitsharesAccountManager;
|
||||
private Thread LoadAccountTransactionsThread;
|
||||
private Thread LoadBitsharesAccountNamesThread;
|
||||
private EquivalencesThread LoadEquivalencesThread;
|
||||
private boolean keepLoadingAccountTransactions;
|
||||
private boolean keepLoadingEquivalences;
|
||||
|
@ -64,6 +68,23 @@ public class CrystalWalletService extends LifecycleService {
|
|||
}
|
||||
}
|
||||
|
||||
public void loadBitsharesAccountNames(){
|
||||
final LifecycleService service = this;
|
||||
final LiveData<List<BitsharesAccountNameCache>> uncachedBitsharesAccountNames =
|
||||
CrystalDatabase.getAppDatabase(service).bitsharesAccountNameCacheDao().getUncachedBitsharesAccountName();
|
||||
|
||||
uncachedBitsharesAccountNames.observe(service, new Observer<List<BitsharesAccountNameCache>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<BitsharesAccountNameCache> bitsharesAccountNameCacheList) {
|
||||
for (BitsharesAccountNameCache nextAccountId : bitsharesAccountNameCacheList){
|
||||
GetBitsharesAccountNameCacheRequest request = new GetBitsharesAccountNameCacheRequest(service, nextAccountId.getAccountId());
|
||||
|
||||
CryptoNetInfoRequests.getInstance().addRequest(request);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadEquivalentsValues(){
|
||||
this.keepLoadingEquivalences = true;
|
||||
final LifecycleService service = this;
|
||||
|
@ -189,16 +210,16 @@ public class CrystalWalletService extends LifecycleService {
|
|||
};
|
||||
LoadAccountTransactionsThread.start();
|
||||
}
|
||||
|
||||
//if (LoadEquivalencesThread == null) {
|
||||
// LoadEquivalencesThread = new EquivalencesThread() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
if (LoadBitsharesAccountNamesThread == null) {
|
||||
LoadBitsharesAccountNamesThread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadBitsharesAccountNames();
|
||||
}
|
||||
};
|
||||
LoadBitsharesAccountNamesThread.start();
|
||||
}
|
||||
loadEquivalentsValues();
|
||||
// }
|
||||
// };
|
||||
// LoadEquivalencesThread.start();
|
||||
// }
|
||||
|
||||
// If we get killed, after returning from here, restart
|
||||
return START_STICKY;
|
||||
|
|
Loading…
Reference in a new issue