@@ -0,0 +1,1589 @@
+package com.simplenote.android.thread;%0A%0Aimport android.app.Activity;%0A%0Aimport com.simplenote.android.Constants;%0Aimport com.simplenote.android.model.Note;%0Aimport com.simplenote.android.net.HttpCallback;%0Aimport com.simplenote.android.net.ServerCreateCallback;%0Aimport com.simplenote.android.net.ServerSaveCallback;%0Aimport com.simplenote.android.net.SimpleNoteApi;%0Aimport com.simplenote.android.persistence.SimpleNoteDao;%0A%0Apublic class SendNotesThread extends Thread %7B%0A%09private final Activity context;%0A%09private final SimpleNoteDao dao;%0A%09private final String email;%0A%09private final String token;%0A%09/**%0A%09 * Create a thread with all the pieces it needs to update notes%0A%09 * @param context Android Activity context in which this thread runs%0A%09 * @param dao interface to the SimpleNote database%0A%09 * @param email of account to sync notes for%0A%09 * @param token authentication token for email%0A%09 */%0A%09public SendNotesThread(Activity context, SimpleNoteDao dao, String email, String token) %7B%0A%09%09this.context = context;%0A%09%09this.dao = dao;%0A%09%09this.email = email;%0A%09%09this.token = token;%0A%09%7D%0A%09/**%0A%09 * Pulls down notes from the server if the server version is newer than the note in the%0A%09 * database%0A%09 * @see java.lang.Thread#run()%0A%09 */%0A%09@Override%0A%09public void run() %7B%0A%09%09// Fetch the notes from the server%0A%09%09Note%5B%5D notes = dao.retrieveUnsynced();%0A%09%09for (Note dbNote : notes) %7B%0A%09%09%09if (dbNote.getKey().equals(%22%22)) %7B%0A%09%09%09%09SimpleNoteApi.create(dbNote, token, email, new ServerCreateCallback(context, dbNote));%0A%09%09%09%7D else %7B%0A%09%09%09%09SimpleNoteApi.update(dbNote, token, email, new ServerSaveCallback(context, dbNote));%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add thread subclass to send unsynced notes to the server