mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-22 04:46:04 +03:00
Auto-save without sync if sync is not possible
This commit is contained in:
parent
141a3373f3
commit
92917f0cce
4 changed files with 37 additions and 19 deletions
|
@ -108,24 +108,22 @@ public class EditNoteActivity extends AppCompatActivity implements CategoryDialo
|
|||
|
||||
@Override
|
||||
public void afterTextChanged(final Editable s) {
|
||||
if(db.getNoteServerSyncHelper().isSyncPossible()) {
|
||||
if(timer != null) {
|
||||
timer.cancel();
|
||||
}
|
||||
if(!saveActive) {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
autoSave();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, DELAY);
|
||||
}
|
||||
if(timer != null) {
|
||||
timer.cancel();
|
||||
}
|
||||
if(!saveActive) {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
autoSave();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, DELAY);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -288,6 +286,15 @@ public class EditNoteActivity extends AppCompatActivity implements CategoryDialo
|
|||
saveData(new ICallback() {
|
||||
@Override
|
||||
public void onFinish() {
|
||||
onSaved();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScheduled() {
|
||||
onSaved();
|
||||
}
|
||||
|
||||
public void onSaved() {
|
||||
// AFTER SYNCHRONIZATION
|
||||
Log.d(LOG_TAG, "...sync finished");
|
||||
actionBar.setTitle(note.getTitle());
|
||||
|
|
|
@ -67,7 +67,11 @@ public class NotesListViewActivity extends AppCompatActivity implements
|
|||
refreshList();
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onScheduled() {
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
|
|
@ -184,8 +184,14 @@ public class NoteServerSyncHelper {
|
|||
} else if(!onlyLocalChanges) {
|
||||
Log.d(getClass().getSimpleName(), "... scheduled");
|
||||
syncScheduled = true;
|
||||
for (ICallback callback : callbacksPush) {
|
||||
callback.onScheduled();
|
||||
}
|
||||
} else {
|
||||
Log.d(getClass().getSimpleName(), "... do nothing");
|
||||
for (ICallback callback : callbacksPush) {
|
||||
callback.onScheduled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,4 +6,5 @@ package it.niedermann.owncloud.notes.util;
|
|||
*/
|
||||
public interface ICallback {
|
||||
void onFinish();
|
||||
void onScheduled();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue