Fixed out of memory on viewing large original messages

pull/145/head
M66B 6 years ago
parent 4fb2e7dbc2
commit f93e4ca813

@ -796,26 +796,16 @@ public class FragmentMessage extends FragmentEx {
} }
private void onMenuShowHtml() { private void onMenuShowHtml() {
new SimpleTask<String>() { Bundle args = new Bundle();
@Override args.putLong("id", message.id);
protected String onLoad(Context context, Bundle args) throws Throwable { args.putString("from", MessageHelper.getFormattedAddresses(message.from, true));
return message.read(context);
}
@Override
protected void onLoaded(Bundle a, String html) {
Bundle args = new Bundle();
args.putString("html", html);
args.putString("from", MessageHelper.getFormattedAddresses(message.from, true));
FragmentWebView fragment = new FragmentWebView(); FragmentWebView fragment = new FragmentWebView();
fragment.setArguments(args); fragment.setArguments(args);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("webview"); fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("webview");
fragmentTransaction.commit(); fragmentTransaction.commit();
}
}.load(this, new Bundle());
} }
private void onMenuUnseen() { private void onMenuUnseen() {

@ -19,6 +19,7 @@ package eu.faircode.email;
Copyright 2018 by Marcel Bokhorst (M66B) Copyright 2018 by Marcel Bokhorst (M66B)
*/ */
import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -82,11 +83,26 @@ public class FragmentWebView extends FragmentEx {
String url = args.getString("url"); String url = args.getString("url");
webview.loadUrl(url); webview.loadUrl(url);
setSubtitle(url); setSubtitle(url);
} else if (args.containsKey("html")) { } else if (args.containsKey("id")) {
String html = args.getString("html"); new SimpleTask<String>() {
String from = args.getString("from"); @Override
webview.loadDataWithBaseURL("email://", html, "text/html", "UTF-8", null); protected String onLoad(Context context, Bundle args) throws Throwable {
setSubtitle(from); long id = args.getLong("id");
return EntityMessage.read(context, id);
}
@Override
protected void onLoaded(Bundle args, String html) {
String from = args.getString("from");
webview.loadDataWithBaseURL("email://", html, "text/html", "UTF-8", null);
setSubtitle(from);
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), ex);
}
}.load(this, args);
} }
((ActivityBase) getActivity()).addBackPressedListener(new ActivityBase.IBackPressedListener() { ((ActivityBase) getActivity()).addBackPressedListener(new ActivityBase.IBackPressedListener() {

Loading…
Cancel
Save