mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-22 04:46:04 +03:00
#66 Handle remote note deleted
This commit is contained in:
parent
f06621400a
commit
edf066df85
2 changed files with 12 additions and 8 deletions
|
@ -163,9 +163,9 @@ public class NotesListViewActivity extends AppCompatActivity implements
|
||||||
Note currentNote = noteList.get(i);
|
Note currentNote = noteList.get(i);
|
||||||
if (!todaySet && recent.getTimeInMillis() - currentNote.getModified().getTimeInMillis() >= 600000 && currentNote.getModified().getTimeInMillis() >= today.getTimeInMillis()) {
|
if (!todaySet && recent.getTimeInMillis() - currentNote.getModified().getTimeInMillis() >= 600000 && currentNote.getModified().getTimeInMillis() >= today.getTimeInMillis()) {
|
||||||
// < 10 minutes but after 00:00 today
|
// < 10 minutes but after 00:00 today
|
||||||
if (i > 0) {
|
//if (i > 0) {
|
||||||
//itemList.add(new SectionItem(getResources().getString(R.string.listview_updated_today)));
|
//itemList.add(new SectionItem(getResources().getString(R.string.listview_updated_today)));
|
||||||
}
|
//}
|
||||||
todaySet = true;
|
todaySet = true;
|
||||||
} else if (!yesterdaySet && currentNote.getModified().getTimeInMillis() < today.getTimeInMillis() && currentNote.getModified().getTimeInMillis() >= yesterday.getTimeInMillis()) {
|
} else if (!yesterdaySet && currentNote.getModified().getTimeInMillis() < today.getTimeInMillis() && currentNote.getModified().getTimeInMillis() >= yesterday.getTimeInMillis()) {
|
||||||
// between today 00:00 and yesterday 00:00
|
// 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) {
|
public boolean onNoteLongClick(int position, View v) {
|
||||||
boolean selected = adapter.select(position);
|
boolean selected = adapter.select(position);
|
||||||
if (selected) {
|
if (selected) {
|
||||||
v.setSelected(selected);
|
v.setSelected(true);
|
||||||
mActionMode = startSupportActionMode(new MultiSelectedActionModeCallback());
|
mActionMode = startSupportActionMode(new MultiSelectedActionModeCallback());
|
||||||
int checkedItemCount = adapter.getSelected().size();
|
int checkedItemCount = adapter.getSelected().size();
|
||||||
mActionMode.setTitle(getResources().getQuantityString(R.plurals.ab_selected, checkedItemCount, checkedItemCount));
|
mActionMode.setTitle(getResources().getQuantityString(R.plurals.ab_selected, checkedItemCount, checkedItemCount));
|
||||||
|
|
|
@ -155,12 +155,15 @@ public class NoteServerSyncHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class UploadEditedNotesTask extends AsyncTask<Object, Void, Note> {
|
private class UploadEditedNotesTask extends AsyncTask<Object, Void, Note> {
|
||||||
|
private String noteContent;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Note doInBackground(Object... params) {
|
protected Note doInBackground(Object... params) {
|
||||||
operationsCount++;
|
operationsCount++;
|
||||||
|
Note oldNote = (Note) params[0];
|
||||||
|
noteContent = oldNote.getContent();
|
||||||
try {
|
try {
|
||||||
Note oldNote = (Note) params[0];
|
return client.editNote(oldNote.getId(), noteContent);
|
||||||
return client.editNote(oldNote.getId(), oldNote.getContent());
|
|
||||||
} catch (IOException | JSONException e) {
|
} catch (IOException | JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -169,9 +172,10 @@ public class NoteServerSyncHelper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Note note) {
|
protected void onPostExecute(Note note) {
|
||||||
if (note != null) {
|
if (note == null) {
|
||||||
// Note has been deleted on server?
|
// Note has been deleted on server -> recreate
|
||||||
// Maybe handle with Pop-Up and ask if Note should be local deleted or recreated on server.
|
db.addNoteAndSync(noteContent);
|
||||||
|
} else {
|
||||||
db.updateNote(note);
|
db.updateNote(note);
|
||||||
}
|
}
|
||||||
asyncTaskFinished();
|
asyncTaskFinished();
|
||||||
|
|
Loading…
Reference in a new issue