|
|
@ -29,6 +29,7 @@ import com.todoroo.astrid.billing.BillingConstants;
|
|
|
|
import com.todoroo.astrid.dao.Database;
|
|
|
|
import com.todoroo.astrid.dao.Database;
|
|
|
|
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
|
|
|
|
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
|
|
|
|
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
|
|
|
|
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.dao.UserDao;
|
|
|
|
import com.todoroo.astrid.data.Metadata;
|
|
|
|
import com.todoroo.astrid.data.Metadata;
|
|
|
|
import com.todoroo.astrid.data.TagData;
|
|
|
|
import com.todoroo.astrid.data.TagData;
|
|
|
|
import com.todoroo.astrid.data.Task;
|
|
|
|
import com.todoroo.astrid.data.Task;
|
|
|
@ -60,6 +61,8 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired MetadataService metadataService;
|
|
|
|
@Autowired MetadataService metadataService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired UserDao userDao;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired Database database;
|
|
|
|
@Autowired Database database;
|
|
|
|
|
|
|
|
|
|
|
|
private final PushQueuedArgs<Task> taskPusher = new PushQueuedArgs<Task>() {
|
|
|
|
private final PushQueuedArgs<Task> taskPusher = new PushQueuedArgs<Task>() {
|
|
|
@ -92,6 +95,19 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final PushQueuedArgs<User> userPusher = new PushQueuedArgs<User>() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public User getRemoteModelInstance(TodorooCursor<User> cursor) {
|
|
|
|
|
|
|
|
return new User(cursor);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void pushRemoteModel(User model) {
|
|
|
|
|
|
|
|
actFmSyncService.pushUser(model);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private final PushQueuedArgs<Metadata> filesPusher = new PushQueuedArgs<Metadata>() {
|
|
|
|
private final PushQueuedArgs<Metadata> filesPusher = new PushQueuedArgs<Metadata>() {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -160,7 +176,7 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
|
|
|
|
actFmPreferenceService.recordSyncStart();
|
|
|
|
actFmPreferenceService.recordSyncStart();
|
|
|
|
updateUserStatus();
|
|
|
|
updateUserStatus();
|
|
|
|
|
|
|
|
|
|
|
|
startUsersFetcher(callback, finisher);
|
|
|
|
startUsersSync(callback, finisher);
|
|
|
|
|
|
|
|
|
|
|
|
startTagFetcher(callback, finisher);
|
|
|
|
startTagFetcher(callback, finisher);
|
|
|
|
|
|
|
|
|
|
|
@ -207,13 +223,14 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** fetch changes to users/friends */
|
|
|
|
/** fetch changes to users/friends */
|
|
|
|
private void startUsersFetcher(final SyncResultCallback callback,
|
|
|
|
private void startUsersSync(final SyncResultCallback callback,
|
|
|
|
final AtomicInteger finisher) {
|
|
|
|
final AtomicInteger finisher) {
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
int time = Preferences.getInt(LAST_USERS_FETCH_TIME, 0);
|
|
|
|
int time = Preferences.getInt(LAST_USERS_FETCH_TIME, 0);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
pushQueuedUsers(callback, finisher);
|
|
|
|
time = actFmSyncService.fetchUsers();
|
|
|
|
time = actFmSyncService.fetchUsers();
|
|
|
|
Preferences.setInt(LAST_USERS_FETCH_TIME, time);
|
|
|
|
Preferences.setInt(LAST_USERS_FETCH_TIME, time);
|
|
|
|
} catch (JSONException e) {
|
|
|
|
} catch (JSONException e) {
|
|
|
@ -397,6 +414,17 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void pushQueuedUsers(final SyncResultCallback callback,
|
|
|
|
|
|
|
|
final AtomicInteger finisher) {
|
|
|
|
|
|
|
|
TodorooCursor<User> users = userDao.query(Query.select(User.PROPERTIES).where(
|
|
|
|
|
|
|
|
Criterion.and(User.PENDING_STATUS.isNotNull(), Functions.length(User.PENDING_STATUS).gt(0))));
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
pushQueued(callback, finisher, users, true, userPusher);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
users.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --- synchronize list
|
|
|
|
// --- synchronize list
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|