You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
This is not a bug but a discussion of a feature request.
TL;DR extend AA to execute methods only in certain life-cycle states
In my code I have to repeatedly check if a method annotated with @UiThread is not being called after the activity / fragment has been destroyed. Most of the time this occurs when a long running background operation returns to display its result.
@UiThreadprotectedvoidfoo() {
if (!isResumed()) {
return;
}
// [...]
}
To prevent to write this check manually every time my idea was to add a parameter lifespan to the @UiThread annotation (Or whatever because I'm bad at naming things). Its values could be the following:
enumLIFESPAN {
CREATED, //valid between onCreate and onDestroySTARTED, //valid between onStart and onStopRESUMED//valid between onResume and onPause
};
An annotated method would look this way:
@UiThread(lifespan = RESUMED)
protectedvoidfoo() {
// [...] executed when activity / fragment is in resumed state
}
The generated class would have to override the onCreate... lifecycle methods to save the current state and query this state inside the generated methods that use the lifespan parameter.
The downside of this idea is that the parameter could only be used in activities or fragments and as a result the @UiThread annotation would not have the same features in all @E... anymore.
An alternate approach would be to create a new annotation similar to @IgnoreWhen that checks for the lifecycle states in @EActivity and @EFragment.
What is your opinion on this matter?
The text was updated successfully, but these errors were encountered:
This is not a bug but a discussion of a feature request.
TL;DR extend AA to execute methods only in certain life-cycle states
In my code I have to repeatedly check if a method annotated with
@UiThread
is not being called after the activity / fragment has been destroyed. Most of the time this occurs when a long running background operation returns to display its result.To prevent to write this check manually every time my idea was to add a parameter
lifespan
to the@UiThread
annotation (Orwhatever
because I'm bad at naming things). Its values could be the following:An annotated method would look this way:
The generated class would have to override the onCreate... lifecycle methods to save the current state and query this state inside the generated methods that use the
lifespan
parameter.The downside of this idea is that the parameter could only be used in activities or fragments and as a result the
@UiThread
annotation would not have the same features in all@E...
anymore.An alternate approach would be to create a new annotation similar to
@IgnoreWhen
that checks for the lifecycle states in@EActivity
and@EFragment
.What is your opinion on this matter?
The text was updated successfully, but these errors were encountered: