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

@ -225,7 +225,7 @@ Welcome to Astrid\'s RTM sync!
- Notifications and repeats are not synchronized.\n - Notifications and repeats are not synchronized.\n
- Moving tasks in RTM to another list and then renaming them causes dupes.\n - Moving tasks in RTM to another list and then renaming them causes dupes.\n
- Deleting tasks in RTM is not detected.\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 Wish me luck!\n
</string> </string>
<string name="sync_now">Synchronize Now!</string> <string name="sync_now">Synchronize Now!</string>

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

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

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

@ -363,13 +363,23 @@ public abstract class SynchronizationService {
stats.localUpdatedTasks++; stats.localUpdatedTasks++;
if(mapping == null) { if(mapping == null) {
mapping = new SyncMapping(task.getTaskIdentifier(), remoteTask); // try looking for this task
syncController.saveSyncMapping(mapping); 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++; stats.localCreatedTasks++;
} }
Notifications.updateAlarm(activity, taskController, alertController, Notifications.updateAlarm(activity, taskController, alertController,
task); task);
syncHandler.post(new ProgressUpdater(stats.localUpdatedTasks,
remoteTasks.size()));
} }
stats.localUpdatedTasks -= stats.localCreatedTasks; stats.localUpdatedTasks -= stats.localCreatedTasks;

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

Loading…
Cancel
Save