Pass modified_after to tags_list in sync logic

pull/14/head
Tim Su 14 years ago
parent be9ebf52e2
commit 9fb085561c

@ -129,8 +129,7 @@ public class ActFmSyncProvider extends SyncProvider<ActFmTaskContainer> {
int serverTime = Preferences.getInt(ActFmPreferenceService.PREF_SERVER_TIME, 0); int serverTime = Preferences.getInt(ActFmPreferenceService.PREF_SERVER_TIME, 0);
ArrayList<ActFmTaskContainer> remoteTasks = new ArrayList<ActFmTaskContainer>(); ArrayList<ActFmTaskContainer> remoteTasks = new ArrayList<ActFmTaskContainer>();
serverTime = (int)(fetchRemoteTasks(serverTime, remoteTasks) - DateUtilities.now()/1000L); int newServerTime = fetchRemoteTasks(serverTime, remoteTasks);
fetchRemoteTagData(serverTime); fetchRemoteTagData(serverTime);
SyncData<ActFmTaskContainer> syncData = populateSyncData(remoteTasks); SyncData<ActFmTaskContainer> syncData = populateSyncData(remoteTasks);
@ -142,8 +141,7 @@ public class ActFmSyncProvider extends SyncProvider<ActFmTaskContainer> {
syncData.localUpdated.close(); syncData.localUpdated.close();
} }
serverTime += DateUtilities.now()/1000L; Preferences.setInt(ActFmPreferenceService.PREF_SERVER_TIME, newServerTime);
Preferences.setInt(ActFmPreferenceService.PREF_SERVER_TIME, serverTime);
actFmPreferenceService.recordSuccessfulSync(); actFmPreferenceService.recordSuccessfulSync();
syncSuccess = true; syncSuccess = true;
@ -165,7 +163,7 @@ public class ActFmSyncProvider extends SyncProvider<ActFmTaskContainer> {
* @param serverTime last sync time * @param serverTime last sync time
*/ */
private void fetchRemoteTagData(int serverTime) throws ActFmServiceException, IOException, JSONException { private void fetchRemoteTagData(int serverTime) throws ActFmServiceException, IOException, JSONException {
actFmSyncService.fetchTags(); actFmSyncService.fetchTags(serverTime);
} }
/** /**

@ -457,12 +457,14 @@ public final class ActFmSyncService {
/** /**
* Fetch all tags * Fetch all tags
* @param serverTime
*/ */
public void fetchTags() throws JSONException, IOException { public void fetchTags(int serverTime) throws JSONException, IOException {
if(!checkForToken()) if(!checkForToken())
return; return;
JSONObject result = actFmInvoker.invoke("tag_list", "token", token); JSONObject result = actFmInvoker.invoke("tag_list",
"token", token, "modified_after", serverTime);
JSONArray tags = result.getJSONArray("list"); JSONArray tags = result.getJSONArray("list");
HashSet<Long> remoteIds = new HashSet<Long>(tags.length()); HashSet<Long> remoteIds = new HashSet<Long>(tags.length());
for(int i = 0; i < tags.length(); i++) { for(int i = 0; i < tags.length(); i++) {

@ -411,7 +411,7 @@ public class FilterListActivity extends ExpandableListActivity {
@Override @Override
public void run() { public void run() {
try { try {
actFmSyncService.fetchTags(); actFmSyncService.fetchTags(0);
adapter.clear(); adapter.clear();
adapter.getLists(); adapter.getLists();

Loading…
Cancel
Save