Skip to content

Commit 322083f

Browse files
authored
Merge pull request #880 from Automattic/issue/879-note-sync-pause
Issue/879 note sync pause
2 parents 406e25d + e0bc90f commit 322083f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Simplenote/src/main/java/com/automattic/simplenote/NoteEditorFragment.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public void run() {
127127
private String mMatchOffsets;
128128
private int mCurrentCursorPosition;
129129
private HistoryBottomSheetDialog mHistoryBottomSheet;
130+
private boolean mIsPaused;
130131
// Hides the history bottom sheet if no revisions are loaded
131132
private final Runnable mHistoryTimeoutRunnable = new Runnable() {
132133
@Override
@@ -434,9 +435,7 @@ public void run() {
434435
@Override
435436
public void onPause() {
436437
super.onPause(); // Always call the superclass method first
437-
438-
mNotesBucket.removeListener(this);
439-
mNotesBucket.stop();
438+
mIsPaused = true;
440439

441440
// Hide soft keyboard if it is showing...
442441
DisplayUtils.hideKeyboard(mContentEditText);
@@ -459,6 +458,13 @@ public void onPause() {
459458
saveNote();
460459
}
461460

461+
@Override
462+
public void onDestroy() {
463+
super.onDestroy();
464+
mNotesBucket.removeListener(this);
465+
mNotesBucket.stop();
466+
}
467+
462468
@Override
463469
public void onSaveInstanceState(@NonNull Bundle outState) {
464470
super.onSaveInstanceState(outState);
@@ -1234,7 +1240,10 @@ public void run() {
12341240

12351241
@Override
12361242
public void onSaveObject(Bucket<Note> noteBucket, Note note) {
1237-
// noop
1243+
if (mIsPaused) {
1244+
mNotesBucket.removeListener(this);
1245+
mNotesBucket.stop();
1246+
}
12381247
}
12391248

12401249
@Override

0 commit comments

Comments
 (0)