/** * Request Activities (Status/Timeline) events from Server. * * @param refresh boolean - is true when fetching latest statuses, false - when older */ private void requestStatusesFromServer(boolean refresh) { if (!checkConnectivity()) { mRequestActivitiesRequired = true; return; } mRequestActivitiesRequired = false; if (!isContactSyncReady() || !EngineManager.getInstance().getContactSyncEngine().isFirstTimeSyncComplete()) { // this method will then call completeUiRequest(status, null); onSyncHelperComplete(ServiceStatus.ERROR_NOT_READY); return; } mLastStatusUpdated = StateTable.fetchLatestStatusUpdateTime(mDb.getReadableDatabase()); mOldestStatusUpdated = StateTable.fetchOldestStatusUpdate(mDb.getReadableDatabase()); LogUtils.logD("ActivityEngine getActivites last update = " + mLastStatusUpdated); int reqId = Activities.getActivities(this, null, applyActivitiesFilter(refresh)); if (reqId > 0) { setReqId(reqId); enqueueRequest( reqId, refresh ? ActivitiesState.UPDATING_STATUSES : ActivitiesState.FETCHING_OLDER_STATUSES); if (mLastStatusUpdated == 0) { newState(State.FETCH_STATUSES_FIRST_TIME); } else { newState(State.UPDATE_STATUSES); } } }
private void updateOldestStatusUpdateTime() { long tloStatus = StateTable.fetchLatestStatusUpdateTime(mDb.getReadableDatabase()); // modify the timelines dates if (mOldestStatusUpdated < tloStatus) { StateTable.modifyOldestStatusTime(mOldestStatusUpdated, mDb.getWritableDatabase()); LogUtils.logD("ActivityEngine: oldest status update set to = " + mOldestStatusUpdated); } }