Esempio n. 1
0
  private synchronized void updateLocalTradeSessions(Collection<TradeSession> remoteList) {
    // Get all the local sessions
    Collection<TradeSession> localList = _db.getAll();

    // Iterate over local items to find records to delete or update locally
    Iterator<TradeSession> localIt = localList.iterator();
    while (localIt.hasNext()) {
      TradeSession localItem = localIt.next();
      TradeSession remoteItem = findAndEliminate(localItem, remoteList);
      if (remoteItem == null) {
        // A local item is not in the remote list, remove it locally
        _db.delete(localItem.id);
      } else {
        // A local item is in the new list, see if it needs to be updated
        if (needsUpdate(localItem, remoteItem)) {
          _db.update(remoteItem);
        }
      }
    }

    // Iterate over remaining remote items and insert them
    Iterator<TradeSession> remoteIt = remoteList.iterator();
    while (remoteIt.hasNext()) {
      TradeSession remoteItem = remoteIt.next();
      _db.insert(remoteItem);
    }
  }
Esempio n. 2
0
 public void unsetLocalTraderAccount() {
   _session = null;
   _localTraderAddress = null;
   _localTraderAccountId = null;
   _localTraderPrivateKey = null;
   _localTraderPrivateKeyString = null;
   _nickname = null;
   SharedPreferences.Editor editor = getEditor();
   editor.remove(Constants.LOCAL_TRADER_KEY_SETTING);
   editor.remove(Constants.LOCAL_TRADER_ACCOUNT_ID_SETTING);
   editor.remove(Constants.LOCAL_TRADER_ADDRESS_SETTING);
   editor.remove(Constants.LOCAL_TRADER_NICKNAME_SETTING);
   setLastTraderSynchronization(0);
   _db.deleteAll();
   editor.commit();
 }
Esempio n. 3
0
 private synchronized void updateSingleTradeSession(TradeSession item) {
   _db.insert(item);
 }
Esempio n. 4
0
 public synchronized void markViewed(TradeSession tradeSession) {
   _db.markViewed(tradeSession);
 }
Esempio n. 5
0
 public synchronized boolean isViewed(TradeSession tradeSession) {
   return _db.getViewTimeById(tradeSession.id) >= tradeSession.lastChange;
 }
Esempio n. 6
0
 public synchronized int countLocalSellTradeSessions() {
   return _db.countSellTradeSessions();
 }
Esempio n. 7
0
 public synchronized int countLocalBuyTradeSessions() {
   return _db.countBuyTradeSessions();
 }
Esempio n. 8
0
 public synchronized Collection<TradeSession> getLocalSellTradeSessions() {
   return _db.getSellTradeSessions();
 }
Esempio n. 9
0
 /** May return null */
 public synchronized TradeSession getLocalTradeSession(UUID tradeSessionId) {
   return _db.get(tradeSessionId);
 }