Save subtitle

pull/50/head
M66B 6 years ago
parent 2bf32e2748
commit 6782351869

@ -52,10 +52,18 @@ public class FragmentEx extends Fragment {
finish = true; finish = true;
} }
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString("subtitle", subtitle);
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
Log.i(Helper.TAG, "Create " + this); Log.i(Helper.TAG, "Create " + this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (savedInstanceState != null)
subtitle = savedInstanceState.getString("subtitle");
} }
@Override @Override

@ -307,6 +307,8 @@ public class FragmentMessage extends FragmentEx {
// Observe message // Observe message
db.message().liveMessage(id).observe(getViewLifecycleOwner(), new Observer<TupleMessageEx>() { db.message().liveMessage(id).observe(getViewLifecycleOwner(), new Observer<TupleMessageEx>() {
private boolean once = false;
@Override @Override
public void onChanged(@Nullable final TupleMessageEx message) { public void onChanged(@Nullable final TupleMessageEx message) {
if (message == null || (!(debug && BuildConfig.DEBUG) && message.ui_hide)) { if (message == null || (!(debug && BuildConfig.DEBUG) && message.ui_hide)) {
@ -316,9 +318,14 @@ public class FragmentMessage extends FragmentEx {
} }
FragmentMessage.this.message = message; FragmentMessage.this.message = message;
setSubtitle(Helper.localizeFolderName(getContext(), message.folderName));
if (savedInstanceState == null) { if (savedInstanceState == null) {
if (once)
return;
once = true;
setSubtitle(Helper.localizeFolderName(getContext(), message.folderName));
tvFrom.setText(message.from == null ? null : MessageHelper.getFormattedAddresses(message.from, true)); tvFrom.setText(message.from == null ? null : MessageHelper.getFormattedAddresses(message.from, true));
tvTime.setText(message.sent == null ? null : df.format(new Date(message.sent))); tvTime.setText(message.sent == null ? null : df.format(new Date(message.sent)));
tvTo.setText(message.to == null ? null : MessageHelper.getFormattedAddresses(message.to, true)); tvTo.setText(message.to == null ? null : MessageHelper.getFormattedAddresses(message.to, true));

Loading…
Cancel
Save