mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-27 02:07:12 +00:00
Load body when needed only
This commit is contained in:
parent
6782351869
commit
f0c5f6fedd
1 changed files with 25 additions and 19 deletions
|
@ -338,6 +338,7 @@ public class FragmentMessage extends FragmentEx {
|
||||||
tvBcc.setText(message.bcc == null ? null : MessageHelper.getFormattedAddresses(message.bcc, true));
|
tvBcc.setText(message.bcc == null ? null : MessageHelper.getFormattedAddresses(message.bcc, true));
|
||||||
|
|
||||||
tvError.setText(message.error);
|
tvError.setText(message.error);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
free = savedInstanceState.getBoolean("free");
|
free = savedInstanceState.getBoolean("free");
|
||||||
if (free) {
|
if (free) {
|
||||||
|
@ -350,27 +351,31 @@ public class FragmentMessage extends FragmentEx {
|
||||||
|
|
||||||
getActivity().invalidateOptionsMenu();
|
getActivity().invalidateOptionsMenu();
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
if (tvBody.getTag() == null) {
|
||||||
args.putLong("id", message.id);
|
// Spanned text needs to be loaded after recreation too
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putLong("id", message.id);
|
||||||
|
|
||||||
pbBody.setVisibility(View.VISIBLE);
|
pbBody.setVisibility(View.VISIBLE);
|
||||||
new SimpleTask<Spanned>() {
|
new SimpleTask<Spanned>() {
|
||||||
@Override
|
@Override
|
||||||
protected Spanned onLoad(Context context, Bundle args) throws Throwable {
|
protected Spanned onLoad(Context context, Bundle args) throws Throwable {
|
||||||
String body = EntityMessage.read(context, args.getLong("id"));
|
String body = EntityMessage.read(context, args.getLong("id"));
|
||||||
args.putInt("size", body.length());
|
args.putInt("size", body.length());
|
||||||
return Html.fromHtml(HtmlHelper.sanitize(getContext(), body, false));
|
return Html.fromHtml(HtmlHelper.sanitize(getContext(), body, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLoaded(Bundle args, Spanned body) {
|
protected void onLoaded(Bundle args, Spanned body) {
|
||||||
tvSize.setText(Helper.humanReadableByteCount(args.getInt("size"), false));
|
tvSize.setText(Helper.humanReadableByteCount(args.getInt("size"), false));
|
||||||
tvBody.setText(body);
|
tvBody.setText(body);
|
||||||
grpMessage.setVisibility(View.VISIBLE);
|
tvBody.setTag(true);
|
||||||
fab.setVisibility(free ? View.GONE : View.VISIBLE);
|
grpMessage.setVisibility(View.VISIBLE);
|
||||||
pbBody.setVisibility(View.GONE);
|
fab.setVisibility(free ? View.GONE : View.VISIBLE);
|
||||||
}
|
pbBody.setVisibility(View.GONE);
|
||||||
}.load(FragmentMessage.this, args);
|
}
|
||||||
|
}.load(FragmentMessage.this, args);
|
||||||
|
}
|
||||||
|
|
||||||
int typeface = (message.ui_seen ? Typeface.NORMAL : Typeface.BOLD);
|
int typeface = (message.ui_seen ? Typeface.NORMAL : Typeface.BOLD);
|
||||||
tvFrom.setTypeface(null, typeface);
|
tvFrom.setTypeface(null, typeface);
|
||||||
|
@ -411,6 +416,7 @@ public class FragmentMessage extends FragmentEx {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Observe folders
|
||||||
db.folder().liveFolders(message.account).removeObservers(getViewLifecycleOwner());
|
db.folder().liveFolders(message.account).removeObservers(getViewLifecycleOwner());
|
||||||
db.folder().liveFolders(message.account).observe(getViewLifecycleOwner(), new Observer<List<TupleFolderEx>>() {
|
db.folder().liveFolders(message.account).observe(getViewLifecycleOwner(), new Observer<List<TupleFolderEx>>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue