#66 Handle remote note deleted

This commit is contained in:
Stefan Niedermann 2016-03-26 11:28:15 +01:00
parent f06621400a
commit edf066df85
2 changed files with 12 additions and 8 deletions

View file

@ -163,9 +163,9 @@ public class NotesListViewActivity extends AppCompatActivity implements
Note currentNote = noteList.get(i);
if (!todaySet && recent.getTimeInMillis() - currentNote.getModified().getTimeInMillis() >= 600000 && currentNote.getModified().getTimeInMillis() >= today.getTimeInMillis()) {
// < 10 minutes but after 00:00 today
if (i > 0) {
//if (i > 0) {
//itemList.add(new SectionItem(getResources().getString(R.string.listview_updated_today)));
}
//}
todaySet = true;
} else if (!yesterdaySet && currentNote.getModified().getTimeInMillis() < today.getTimeInMillis() && currentNote.getModified().getTimeInMillis() >= yesterday.getTimeInMillis()) {
// between today 00:00 and yesterday 00:00
@ -366,7 +366,7 @@ public class NotesListViewActivity extends AppCompatActivity implements
public boolean onNoteLongClick(int position, View v) {
boolean selected = adapter.select(position);
if (selected) {
v.setSelected(selected);
v.setSelected(true);
mActionMode = startSupportActionMode(new MultiSelectedActionModeCallback());
int checkedItemCount = adapter.getSelected().size();
mActionMode.setTitle(getResources().getQuantityString(R.plurals.ab_selected, checkedItemCount, checkedItemCount));

View file

@ -155,12 +155,15 @@ public class NoteServerSyncHelper {
}
private class UploadEditedNotesTask extends AsyncTask<Object, Void, Note> {
private String noteContent;
@Override
protected Note doInBackground(Object... params) {
operationsCount++;
Note oldNote = (Note) params[0];
noteContent = oldNote.getContent();
try {
Note oldNote = (Note) params[0];
return client.editNote(oldNote.getId(), oldNote.getContent());
return client.editNote(oldNote.getId(), noteContent);
} catch (IOException | JSONException e) {
e.printStackTrace();
}
@ -169,9 +172,10 @@ public class NoteServerSyncHelper {
@Override
protected void onPostExecute(Note note) {
if (note != null) {
// Note has been deleted on server?
// Maybe handle with Pop-Up and ask if Note should be local deleted or recreated on server.
if (note == null) {
// Note has been deleted on server -> recreate
db.addNoteAndSync(noteContent);
} else {
db.updateNote(note);
}
asyncTaskFinished();