Enforce all the SliceBackgroundWorkers being singletons at syntax level

- Create workers via reflection in SliceBackgroundWorker
- Store the workers in a static container and release then at shutdown()

Fixes: 118228009
Test: robolectric
Change-Id: I564277d3a12b2d7d3b50cef091bdfedb3397c145
This commit is contained in:
Jason Chiu
2018-10-29 17:58:55 +08:00
committed by Fan Zhang
parent 7ebb059ea5
commit a68f81540e
6 changed files with 124 additions and 90 deletions

View File

@@ -91,11 +91,12 @@ public interface CustomSliceable {
/**
* Settings Slices which can represent component lists that are updatable by the
* {@link SliceBackgroundWorker} returned here.
* {@link SliceBackgroundWorker} class returned here.
*
* @return a {@link SliceBackgroundWorker} for fetching the list of results in the background.
* @return a {@link SliceBackgroundWorker} class for fetching the list of results in the
* background.
*/
default SliceBackgroundWorker getBackgroundWorker() {
default Class<? extends SliceBackgroundWorker> getBackgroundWorkerClass() {
return null;
}