More granular transient states

pull/147/head
M66B 6 years ago
parent 533c763457
commit 099239ca64

@ -309,20 +309,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean show_addresses = !properties.getValue("addresses", message.id); boolean show_addresses = !properties.getValue("addresses", message.id);
boolean show_headers = properties.getValue("headers", message.id); boolean show_headers = properties.getValue("headers", message.id);
if (viewType == ViewType.THREAD) {
if (show_expanded) {
if (!properties.getValue("frozen", message.id)) {
itemView.setHasTransientState(true);
properties.setValue("frozen", message.id, true);
}
} else {
if (properties.getValue("frozen", message.id)) {
itemView.setHasTransientState(false);
properties.setValue("frozen", message.id, false);
}
}
}
pbLoading.setVisibility(View.GONE); pbLoading.setVisibility(View.GONE);
if (viewType == ViewType.THREAD) { if (viewType == ViewType.THREAD) {
@ -532,6 +518,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
sargs.putLong("account", message.account); sargs.putLong("account", message.account);
new SimpleTask<List<EntityFolder>>() { new SimpleTask<List<EntityFolder>>() {
@Override
protected void onInit(Bundle args) {
bnvActions.setHasTransientState(true);
}
@Override
protected void onCleanup(Bundle args) {
bnvActions.setHasTransientState(false);
}
@Override @Override
protected List<EntityFolder> onLoad(Context context, Bundle args) { protected List<EntityFolder> onLoad(Context context, Bundle args) {
long account = args.getLong("account"); long account = args.getLong("account");
@ -745,6 +741,22 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private SimpleTask<Spanned> bodyTask = new SimpleTask<Spanned>() { private SimpleTask<Spanned> bodyTask = new SimpleTask<Spanned>() {
private String body = null; private String body = null;
@Override
protected void onInit(Bundle args) {
btnHtml.setHasTransientState(true);
btnImages.setHasTransientState(true);
tvBody.setHasTransientState(true);
pbBody.setHasTransientState(true);
}
@Override
protected void onCleanup(Bundle args) {
btnHtml.setHasTransientState(false);
btnImages.setHasTransientState(false);
tvBody.setHasTransientState(false);
pbBody.setHasTransientState(false);
}
@Override @Override
protected Spanned onLoad(final Context context, final Bundle args) { protected Spanned onLoad(final Context context, final Bundle args) {
TupleMessageEx message = (TupleMessageEx) args.getSerializable("message"); TupleMessageEx message = (TupleMessageEx) args.getSerializable("message");

@ -117,6 +117,12 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
this.args = null; this.args = null;
this.stored = null; this.stored = null;
try {
onInit(args);
} catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
}
owner.getLifecycle().addObserver(this); owner.getLifecycle().addObserver(this);
final Handler handler = new Handler(); final Handler handler = new Handler();
@ -160,11 +166,19 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
} finally { } finally {
try {
onCleanup(args);
} catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
}
onDestroyed(); onDestroyed();
} }
} }
} }
protected void onInit(Bundle args) {
}
protected abstract T onLoad(Context context, Bundle args) throws Throwable; protected abstract T onLoad(Context context, Bundle args) throws Throwable;
protected void onLoaded(Bundle args, T data) { protected void onLoaded(Bundle args, T data) {
@ -172,6 +186,9 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
protected abstract void onException(Bundle args, Throwable ex); protected abstract void onException(Bundle args, Throwable ex);
protected void onCleanup(Bundle args) {
}
private static class Result { private static class Result {
Throwable ex; Throwable ex;
Object data; Object data;

Loading…
Cancel
Save