Save fragment instance states

This commit is contained in:
M66B
2018-08-15 09:50:39 +00:00
parent ee2d59c406
commit d4199124a7
6 changed files with 268 additions and 87 deletions

View File

@@ -258,11 +258,18 @@ public class FragmentCompose extends FragmentEx {
super.onDestroyView();
}
@Override
public void onSaveInstanceState(Bundle outState) {
if (autosave)
onAction(R.id.action_save);
outState.putLong("working", working);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (working < 0) {
if (savedInstanceState == null) {
Bundle args = new Bundle();
args.putString("action", getArguments().getString("action"));
args.putLong("id", getArguments().getLong("id", -1));
@@ -272,7 +279,7 @@ public class FragmentCompose extends FragmentEx {
} else {
Bundle args = new Bundle();
args.putString("action", "edit");
args.putLong("id", working);
args.putLong("id", savedInstanceState.getLong("working"));
args.putLong("account", -1);
args.putLong("reference", -1);
draftLoader.load(this, args);