|
|
|
@ -173,6 +173,8 @@ public class FetchHomeWorker extends Worker {
|
|
|
|
|
if (fetch_home) {
|
|
|
|
|
int max_calls = 10;
|
|
|
|
|
int status_per_page = 40;
|
|
|
|
|
int insertValue = 0;
|
|
|
|
|
StatusCache lastStatusCache = null;
|
|
|
|
|
//Browse last 400 home messages
|
|
|
|
|
boolean canContinue = true;
|
|
|
|
|
int call = 0;
|
|
|
|
@ -194,9 +196,10 @@ public class FetchHomeWorker extends Worker {
|
|
|
|
|
statusCache.status = status;
|
|
|
|
|
statusCache.type = Timeline.TimeLineEnum.HOME;
|
|
|
|
|
statusCache.status_id = status.id;
|
|
|
|
|
lastStatusCache = statusCache;
|
|
|
|
|
try {
|
|
|
|
|
int insertOrUpdate = statusCacheDAO.insertOrUpdate(statusCache, Timeline.TimeLineEnum.HOME.getValue());
|
|
|
|
|
if (insertOrUpdate == 1) {
|
|
|
|
|
insertValue = statusCacheDAO.insertOrUpdate(statusCache, Timeline.TimeLineEnum.HOME.getValue());
|
|
|
|
|
if (insertValue == 1) {
|
|
|
|
|
inserted++;
|
|
|
|
|
} else {
|
|
|
|
|
updated++;
|
|
|
|
@ -246,7 +249,17 @@ public class FetchHomeWorker extends Worker {
|
|
|
|
|
} catch (DBException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//insertValue is for last status and equals zero if updated or 1 if inserted
|
|
|
|
|
if (lastStatusCache != null && insertValue == 1) { //Last inserted message was not in cache.
|
|
|
|
|
StatusCache statusCacheDAO = new StatusCache(getApplicationContext());
|
|
|
|
|
lastStatusCache.status.isFetchMore = true;
|
|
|
|
|
lastStatusCache.status.positionFetchMore = Status.PositionFetchMore.TOP;
|
|
|
|
|
try {
|
|
|
|
|
statusCacheDAO.updateIfExists(lastStatusCache);
|
|
|
|
|
} catch (DBException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|