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_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);
if (viewType == ViewType.THREAD) {
@ -532,6 +518,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
sargs.putLong("account", message.account);
new SimpleTask<List<EntityFolder>>() {
@Override
protected void onInit(Bundle args) {
bnvActions.setHasTransientState(true);
}
@Override
protected void onCleanup(Bundle args) {
bnvActions.setHasTransientState(false);
}
@Override
protected List<EntityFolder> onLoad(Context context, Bundle args) {
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 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
protected Spanned onLoad(final Context context, final Bundle args) {
TupleMessageEx message = (TupleMessageEx) args.getSerializable("message");

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

Loading…
Cancel
Save