Fixed
Status Update
Comments
gg...@google.com <gg...@google.com> #2
Correction: only the *child* class methods are called.
al...@gmail.com <al...@gmail.com> #3
Also: if I remove the android.arch.lifecycle:compiler dependency, it actually works! So I guess this means it is a bug, which only happens when using the annotation processor.
su...@google.com <su...@google.com> #4
Can you please provide sample project? I wasn't able to reproduce it with my sample + compiler:
public class Empty extends LifecycleActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_empty);
getLifecycle().addObserver(new C());
}
public static class B implements LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
void a() {
System.out.println("!!!!!!!!!!!!!!!!!!!! A");
}
}
public static class C extends B {
void a() {
super.a();
System.out.println("!!!!!!!!!!!!!!!!! A overriden");
}
@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
void b() {
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!! B");
}
}
}
public class Empty extends LifecycleActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_empty);
getLifecycle().addObserver(new C());
}
public static class B implements LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
void a() {
System.out.println("!!!!!!!!!!!!!!!!!!!! A");
}
}
public static class C extends B {
void a() {
super.a();
System.out.println("!!!!!!!!!!!!!!!!! A overriden");
}
@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
void b() {
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!! B");
}
}
}
su...@google.com <su...@google.com> #5
I forgot to mention that the parent and child classes are in 2 different modules - maybe that is the problem.
I will try to find a bit of time to provide a sample project.
I will try to find a bit of time to provide a sample project.
Description
Oftentimes, we have jobs that we'd like to retry - for example, if network cuts out during a background upload - but we don't want to retry them indefinitely. It would be very useful to specify this as part of the work request, especially for jobs for which we wouldn't otherwise manually track state:
```
class MyWorker extends Worker {
@Override
WorkerResult doWork() {
try {
doSomeNetworkThing();
return WorkerResult.SUCCESS;
} catch (IOException e) {
// Oh no, the network is spotty. Retry, unless this is the Nth attempt, in which case
// just fail
if (/**/) { //
return WorkerResult.RETRY;
} else {
return WorkerResult.FAILURE;
}
}
}
}
```
It would be nice if, instead, we could do this declaratively:
```
new OneTimeWorkRequest.Builder(MyWorker.class)
.setBackoffPolicy(BackoffPolicy.exponential().withMaxRetries(10)) // let's just pretend this API exists
.build();
```
The above API would specify a policy such that, if the `MyWorker#doWork()` returns `WorkerResult.RETRY` 10 times, the scheduler will consider that to be equivalent to `WorkerResult.FAILURE`.