Keep message bodies

pull/153/head
M66B 6 years ago
parent 534df441da
commit aad2f18505

@ -149,8 +149,8 @@ public class FragmentMessages extends FragmentBase {
private int autoCloseCount = 0;
private boolean autoExpanded = true;
private Map<String, List<Long>> values = new HashMap<>();
private LongSparseArray<Spanned> bodies = new LongSparseArray<>();
private LongSparseArray<String> html = new LongSparseArray<>();
private Map<Long, Spanned> bodies = new HashMap<>();
private Map<Long, String> html = new HashMap<>();
private LongSparseArray<TupleAccountSwipes> accountSwipes = new LongSparseArray<>();
private BoundaryCallbackMessages boundaryCallback = null;
@ -1485,6 +1485,7 @@ public class FragmentMessages extends FragmentBase {
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean("fair:autoExpanded", autoExpanded);
outState.putInt("fair:autoCloseCount", autoCloseCount);
@ -1492,6 +1493,14 @@ public class FragmentMessages extends FragmentBase {
for (String name : values.keySet())
outState.putLongArray("fair:name:" + name, Helper.toLongArray(values.get(name)));
outState.putLongArray("fair:bodies", Helper.toLongArray(bodies.keySet()));
for (Long key : bodies.keySet())
outState.putString("fair:bodies:" + key, HtmlHelper.toHtml(bodies.get(key)));
outState.putLongArray("fair:html", Helper.toLongArray(html.keySet()));
for (Long key : html.keySet())
outState.putString("fair:html:" + key, html.get(key));
if (rvMessage != null) {
Parcelable rv = rvMessage.getLayoutManager().onSaveInstanceState();
outState.putParcelable("fair:rv", rv);
@ -1509,13 +1518,18 @@ public class FragmentMessages extends FragmentBase {
autoExpanded = savedInstanceState.getBoolean("fair:autoExpanded");
autoCloseCount = savedInstanceState.getInt("fair:autoCloseCount");
String[] names = savedInstanceState.getStringArray("fair:values");
for (String name : names) {
for (String name : savedInstanceState.getStringArray("fair:values")) {
values.put(name, new ArrayList<Long>());
for (Long value : savedInstanceState.getLongArray("fair:name:" + name))
values.get(name).add(value);
}
for (long id : savedInstanceState.getLongArray("fair:bodies"))
bodies.put(id, HtmlHelper.fromHtml(savedInstanceState.getString("fair:bodies:" + id)));
for (long id : savedInstanceState.getLongArray("fair:html"))
html.put(id, savedInstanceState.getString("fair:html:" + id));
if (rvMessage != null) {
Parcelable rv = savedInstanceState.getBundle("fair:rv");
rvMessage.getLayoutManager().onRestoreInstanceState(rv);

@ -88,6 +88,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ThreadFactory;
import javax.mail.Address;
@ -1002,6 +1003,14 @@ public class Helper {
return result;
}
static long[] toLongArray(Set<Long> set) {
long[] result = new long[set.size()];
int i = 0;
for (Long value : set)
result[i++] = value;
return result;
}
static List<Long> fromLongArray(long[] array) {
List<Long> result = new ArrayList<>();
for (int i = 0; i < array.length; i++)

Loading…
Cancel
Save