Updated to handle huge task lists by breaking things down into multiple lists.

pull/14/head
Tim Su 16 years ago
parent afaac7d9f9
commit b9aaa8e95f

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.timsu.astrid"
android:versionCode="60"
android:versionName="2.0.0-rc1">
android:versionCode="61"
android:versionName="2.0.0-rc2">
<meta-data android:name="com.a0soft.gphone.aTrackDog.webURL"
android:value="http://www.weloveastrid.com" />
<meta-data android:name="com.a0soft.gphone.aTrackDog.testVersion"
android:value="60" />
android:value="61" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

@ -225,7 +225,7 @@ Welcome to Astrid\'s RTM sync!
- Notifications and repeats are not synchronized.\n
- Moving tasks in RTM to another list and then renaming them causes dupes.\n
- Deleting tasks in RTM is not detected.\n
- Synchronization is SLOW!\n
- Having ~50+ tasks in one list might cause that list to not be imported\n
Wish me luck!\n
</string>
<string name="sync_now">Synchronize Now!</string>

@ -185,14 +185,14 @@ public class TaskListAdapter extends ArrayAdapter<TaskModelForList> {
if(!task.isTaskCompleted() && task.getEstimatedSeconds() > 0) {
int remaining = task.getEstimatedSeconds() - elapsed;
remainingString = DateUtilities.getShortDurationString(r,
(int)Math.abs(remaining), 1) + " ";
(int)Math.abs(remaining), 1);
if(remaining >= 0)
remainingString += r.getString(R.string.taskList_remaining);
else
remainingString += r.getString(R.string.taskList_overtime);
} else if(elapsed > 0) {
remainingString = DateUtilities.getShortDurationString(r,
(int)Math.abs(elapsed), 1) + " " +
Math.abs(elapsed), 1) +
r.getString(R.string.taskList_spent);
}

@ -316,12 +316,16 @@ public class TaskController extends AbstractController {
AbstractTaskModel.PROGRESS_PERCENTAGE + " < "+
AbstractTaskModel.COMPLETE_PERCENTAGE,
new String[] { name }, null, null, null, null);
if (cursor == null || cursor.getCount() == 0)
return null;
cursor.moveToFirst();
TaskModelForSync model = new TaskModelForSync(cursor);
cursor.close();
return model;
try {
if (cursor == null || cursor.getCount() == 0)
return null;
cursor.moveToFirst();
TaskModelForSync model = new TaskModelForSync(cursor);
return model;
} finally {
if(cursor != null)
cursor.close();
}
}
/** Returns a TaskModelForView corresponding to the given TaskIdentifier */

@ -151,7 +151,6 @@ public class RTMSyncService extends SynchronizationService {
// get RTM timeline
final String timeline = rtmService.timelines_create();
syncHandler.post(new ProgressUpdater(20, 100));
// load RTM lists
RtmLists lists = rtmService.lists_getList();
@ -163,24 +162,40 @@ public class RTMSyncService extends SynchronizationService {
if(INBOX_LIST_NAME.equalsIgnoreCase(list.getName()))
INBOX_LIST_NAME = list.getName();
}
syncHandler.post(new ProgressUpdater(40, 100));
// read all tasks
List<TaskProxy> remoteChanges = new LinkedList<TaskProxy>();
Date lastSyncDate = Preferences.getSyncRTMLastSync(activity);
String filter = "";
if(lastSyncDate == null) // 1st time sync, just uncompleted tasks
filter = "status:incomplete";
RtmTasks tasks = rtmService.tasks_getList(null, filter, lastSyncDate);
syncHandler.post(new ProgressUpdater(100, 100));
int progress = 0;
for(final String listId : listIdToNameMap.keySet()) {
RtmTasks tasks;
try {
tasks = rtmService.tasks_getList(listId, filter, lastSyncDate);
} catch (Exception e) {
syncHandler.post(new Runnable() {
@Override
public void run() {
DialogUtilities.okDialog(activity,
"List " + listIdToNameMap.get(listId) +
" import failed (too big?)", null);
}
});
continue;
}
List<TaskProxy> remoteChanges = new LinkedList<TaskProxy>();
for(RtmTaskList taskList : tasks.getLists()) {
for(RtmTaskSeries taskSeries : taskList.getSeries()) {
TaskProxy remoteTask = parseRemoteTask(taskList.getId(), taskSeries);
remoteChanges.add(remoteTask);
for(RtmTaskList taskList : tasks.getLists()) {
for(RtmTaskSeries taskSeries : taskList.getSeries()) {
TaskProxy remoteTask = parseRemoteTask(taskList.getId(), taskSeries);
remoteChanges.add(remoteTask);
}
}
syncHandler.post(new ProgressUpdater(++progress, listIdToNameMap.size()));
}
synchronizeTasks(activity, remoteChanges, new SynchronizeHelper() {
@Override
public String createTask(String listName) throws IOException {

@ -363,13 +363,23 @@ public abstract class SynchronizationService {
stats.localUpdatedTasks++;
if(mapping == null) {
mapping = new SyncMapping(task.getTaskIdentifier(), remoteTask);
syncController.saveSyncMapping(mapping);
// try looking for this task
mapping = localIdToSyncMapping.get(task.getTaskIdentifier());
if(mapping == null) {
try {
mapping = new SyncMapping(task.getTaskIdentifier(), remoteTask);
syncController.saveSyncMapping(mapping);
} catch (Exception e) {
// ignore - it'll get merged later
}
}
stats.localCreatedTasks++;
}
Notifications.updateAlarm(activity, taskController, alertController,
task);
syncHandler.post(new ProgressUpdater(stats.localUpdatedTasks,
remoteTasks.size()));
}
stats.localUpdatedTasks -= stats.localCreatedTasks;

@ -112,7 +112,7 @@ public class DateUtilities {
result.append(minutes).append(" m ");
unitsDisplayed++;
}
if(unitsDisplayed < unitsToShow && seconds < 0) {
if(unitsDisplayed < unitsToShow && seconds > 0) {
result.append(hours).append(" s ");
}

Loading…
Cancel
Save