Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 599fd150 authored by Stefan Niedermann's avatar Stefan Niedermann
Browse files

Fix #55 Changing screen orientation causes data loss

Solution: use onSaveInstanceState to remember edited note. Because on every screen orientation change onCreate() is called which uses the original given note.
parent cae7402e
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@ public class NoteActivity extends AppCompatActivity implements View.OnClickListe
        setContentView(R.layout.activity_single_note);
        note = (Note) getIntent().getSerializableExtra(
                NotesListViewActivity.SELECTED_NOTE);
        if (savedInstanceState != null) {
            note = (Note) savedInstanceState.getSerializable("note");
        }
        notePosition = getIntent().getIntExtra(
                NotesListViewActivity.SELECTED_NOTE_POSITION, 0);
        findViewById(R.id.fab_edit).setOnClickListener(this);
@@ -41,6 +44,12 @@ public class NoteActivity extends AppCompatActivity implements View.OnClickListe
        findViewById(R.id.fab_edit).setOnClickListener(this);
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        outState.putSerializable("note", note);
        super.onSaveInstanceState(outState);
    }

    @Override
    public void onClick(View v) {
        Intent editIntent = new Intent(this, EditNoteActivity.class);