|
|
|
@ -29,6 +29,7 @@ import com.todoroo.astrid.billing.BillingConstants;
|
|
|
|
|
import com.todoroo.astrid.dao.Database;
|
|
|
|
|
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
|
|
|
|
|
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
|
|
|
|
|
import com.todoroo.astrid.dao.UserDao;
|
|
|
|
|
import com.todoroo.astrid.data.Metadata;
|
|
|
|
|
import com.todoroo.astrid.data.TagData;
|
|
|
|
|
import com.todoroo.astrid.data.Task;
|
|
|
|
@ -60,6 +61,8 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
|
|
|
|
|
|
|
|
|
|
@Autowired MetadataService metadataService;
|
|
|
|
|
|
|
|
|
|
@Autowired UserDao userDao;
|
|
|
|
|
|
|
|
|
|
@Autowired Database database;
|
|
|
|
|
|
|
|
|
|
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>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -160,7 +176,7 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
|
|
|
|
|
actFmPreferenceService.recordSyncStart();
|
|
|
|
|
updateUserStatus();
|
|
|
|
|
|
|
|
|
|
startUsersFetcher(callback, finisher);
|
|
|
|
|
startUsersSync(callback, finisher);
|
|
|
|
|
|
|
|
|
|
startTagFetcher(callback, finisher);
|
|
|
|
|
|
|
|
|
@ -207,13 +223,14 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** fetch changes to users/friends */
|
|
|
|
|
private void startUsersFetcher(final SyncResultCallback callback,
|
|
|
|
|
private void startUsersSync(final SyncResultCallback callback,
|
|
|
|
|
final AtomicInteger finisher) {
|
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
int time = Preferences.getInt(LAST_USERS_FETCH_TIME, 0);
|
|
|
|
|
try {
|
|
|
|
|
pushQueuedUsers(callback, finisher);
|
|
|
|
|
time = actFmSyncService.fetchUsers();
|
|
|
|
|
Preferences.setInt(LAST_USERS_FETCH_TIME, time);
|
|
|
|
|
} 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
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|