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); } }
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(); }
private synchronized void updateSingleTradeSession(TradeSession item) { _db.insert(item); }
public synchronized void markViewed(TradeSession tradeSession) { _db.markViewed(tradeSession); }
public synchronized boolean isViewed(TradeSession tradeSession) { return _db.getViewTimeById(tradeSession.id) >= tradeSession.lastChange; }
public synchronized int countLocalSellTradeSessions() { return _db.countSellTradeSessions(); }
public synchronized int countLocalBuyTradeSessions() { return _db.countBuyTradeSessions(); }
public synchronized Collection<TradeSession> getLocalSellTradeSessions() { return _db.getSellTradeSessions(); }
/** May return null */ public synchronized TradeSession getLocalTradeSession(UUID tradeSessionId) { return _db.get(tradeSessionId); }