Loading app/src/main/java/it/niedermann/owncloud/notes/android/fragment/BaseNoteFragment.java +10 −2 Original line number Diff line number Diff line Loading @@ -64,8 +64,10 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego private SingleSignOnAccount ssoAccount; protected DBNote note; // TODO do we really need this? The reference to note is currently the same @Nullable private DBNote originalNote; private int originalScrollY; protected NotesDatabase db; private NoteFragmentListener listener; Loading Loading @@ -134,7 +136,8 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego super.onActivityCreated(savedInstanceState); final ScrollView scrollView = getScrollView(); if (scrollView != null) { scrollView.post(() -> scrollView.scrollTo(0, note.getScrollY())); this.originalScrollY = note.getScrollY(); scrollView.post(() -> scrollView.scrollTo(0, originalScrollY)); } } Loading Loading @@ -287,7 +290,12 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego if (note != null) { String newContent = getContent(); if (note.getContent().equals(newContent)) { if (note.getScrollY() != originalScrollY) { Log.v(TAG, "... only saving new scroll state, since content did not change"); db.updateScrollY(note.getId(), note.getScrollY()); } else { Log.v(TAG, "... not saving, since nothing has changed"); } } else { note = db.updateNoteAndSync(ssoAccount, localAccount.getId(), note, newContent, callback); listener.onNoteUpdated(note); Loading app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java +2 −1 Original line number Diff line number Diff line Loading @@ -540,10 +540,11 @@ public class NotesDatabase extends AbstractNotesDatabase { } public void updateScrollY(long noteId, int scrollY) { Log.e(TAG, "Updated scrollY: " + scrollY); SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(1); values.put(key_scroll_y, scrollY); db.update(table_notes, values, key_id + " = ? ", new String[]{String.valueOf(scrollY)}); db.update(table_notes, values, key_id + " = ? ", new String[]{String.valueOf(noteId)}); } /** Loading Loading
app/src/main/java/it/niedermann/owncloud/notes/android/fragment/BaseNoteFragment.java +10 −2 Original line number Diff line number Diff line Loading @@ -64,8 +64,10 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego private SingleSignOnAccount ssoAccount; protected DBNote note; // TODO do we really need this? The reference to note is currently the same @Nullable private DBNote originalNote; private int originalScrollY; protected NotesDatabase db; private NoteFragmentListener listener; Loading Loading @@ -134,7 +136,8 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego super.onActivityCreated(savedInstanceState); final ScrollView scrollView = getScrollView(); if (scrollView != null) { scrollView.post(() -> scrollView.scrollTo(0, note.getScrollY())); this.originalScrollY = note.getScrollY(); scrollView.post(() -> scrollView.scrollTo(0, originalScrollY)); } } Loading Loading @@ -287,7 +290,12 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego if (note != null) { String newContent = getContent(); if (note.getContent().equals(newContent)) { if (note.getScrollY() != originalScrollY) { Log.v(TAG, "... only saving new scroll state, since content did not change"); db.updateScrollY(note.getId(), note.getScrollY()); } else { Log.v(TAG, "... not saving, since nothing has changed"); } } else { note = db.updateNoteAndSync(ssoAccount, localAccount.getId(), note, newContent, callback); listener.onNoteUpdated(note); Loading
app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java +2 −1 Original line number Diff line number Diff line Loading @@ -540,10 +540,11 @@ public class NotesDatabase extends AbstractNotesDatabase { } public void updateScrollY(long noteId, int scrollY) { Log.e(TAG, "Updated scrollY: " + scrollY); SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(1); values.put(key_scroll_y, scrollY); db.update(table_notes, values, key_id + " = ? ", new String[]{String.valueOf(scrollY)}); db.update(table_notes, values, key_id + " = ? ", new String[]{String.valueOf(noteId)}); } /** Loading