Subscrip
This commit is contained in:
parent
4434ad40a5
commit
6ce7c453f4
1 changed files with 6 additions and 0 deletions
|
@ -6,6 +6,7 @@ import android.content.Context;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cy.agorise.crystalwallet.dao.BitsharesAssetDao;
|
import cy.agorise.crystalwallet.dao.BitsharesAssetDao;
|
||||||
|
@ -65,6 +66,7 @@ public abstract class GrapheneApiGenerator {
|
||||||
});
|
});
|
||||||
|
|
||||||
private static WebSocketThread subscriptionThread = new WebSocketThread(bitsharesSubscriptionHub,url);
|
private static WebSocketThread subscriptionThread = new WebSocketThread(bitsharesSubscriptionHub,url);
|
||||||
|
private static HashMap<Long,SubscriptionListener> currentBitsharesListener = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the data of an account searching by it's id
|
* Retrieves the data of an account searching by it's id
|
||||||
|
@ -302,6 +304,7 @@ public abstract class GrapheneApiGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void subscribeBitsharesAccount(final long accountId, final String accountBitsharesId, final Context context){
|
public static void subscribeBitsharesAccount(final long accountId, final String accountBitsharesId, final Context context){
|
||||||
|
if(!currentBitsharesListener.containsKey(accountId)){
|
||||||
CrystalDatabase db = CrystalDatabase.getAppDatabase(context);
|
CrystalDatabase db = CrystalDatabase.getAppDatabase(context);
|
||||||
final CryptoCoinBalanceDao balanceDao = db.cryptoCoinBalanceDao();
|
final CryptoCoinBalanceDao balanceDao = db.cryptoCoinBalanceDao();
|
||||||
final BitsharesAssetDao bitsharesAssetDao = db.bitsharesAssetDao();
|
final BitsharesAssetDao bitsharesAssetDao = db.bitsharesAssetDao();
|
||||||
|
@ -357,6 +360,7 @@ public abstract class GrapheneApiGenerator {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
currentBitsharesListener.put(accountId,balanceListener);
|
||||||
bitsharesSubscriptionHub.addSubscriptionListener(balanceListener);
|
bitsharesSubscriptionHub.addSubscriptionListener(balanceListener);
|
||||||
|
|
||||||
if(!subscriptionThread.isConnected()){
|
if(!subscriptionThread.isConnected()){
|
||||||
|
@ -364,6 +368,7 @@ public abstract class GrapheneApiGenerator {
|
||||||
}else if(!bitsharesSubscriptionHub.isSubscribed()){
|
}else if(!bitsharesSubscriptionHub.isSubscribed()){
|
||||||
bitsharesSubscriptionHub.resubscribe();
|
bitsharesSubscriptionHub.resubscribe();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void cancelBitsharesAccountSubcriptions(){
|
public static void cancelBitsharesAccountSubcriptions(){
|
||||||
|
@ -371,6 +376,7 @@ public abstract class GrapheneApiGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getAccountBalance(final long accountId, final String accountGrapheneId, final Context context){
|
public static void getAccountBalance(final long accountId, final String accountGrapheneId, final Context context){
|
||||||
|
|
||||||
CrystalDatabase db = CrystalDatabase.getAppDatabase(context);
|
CrystalDatabase db = CrystalDatabase.getAppDatabase(context);
|
||||||
final CryptoCoinBalanceDao balanceDao = db.cryptoCoinBalanceDao();
|
final CryptoCoinBalanceDao balanceDao = db.cryptoCoinBalanceDao();
|
||||||
final BitsharesAssetDao bitsharesAssetDao = db.bitsharesAssetDao();
|
final BitsharesAssetDao bitsharesAssetDao = db.bitsharesAssetDao();
|
||||||
|
|
Loading…
Reference in a new issue