Move some slice related api out of BasePreferenceController

And share with CustomSliceable.

Bug: 121150258
Test: rebuild
Change-Id: Ia5aed9c156fb168c1f001da6e37f7f12f191b385
This commit is contained in:
Fan Zhang
2019-02-14 15:06:23 -08:00
parent 1aa75aa71a
commit 45f961b624
4 changed files with 74 additions and 56 deletions

View File

@@ -52,7 +52,7 @@ import java.lang.reflect.InvocationTargetException;
* <p>
* If you implement this interface, you should add your Slice to {@link CustomSliceManager}.
*/
public interface CustomSliceable {
public interface CustomSliceable extends Sliceable {
/**
* @return an complete instance of the {@link Slice}.
@@ -78,17 +78,6 @@ public interface CustomSliceable {
*/
Intent getIntent();
/**
* Settings Slices which can represent components that are updatable by the framework should
* listen to changes matched to the {@link IntentFilter} returned here.
*
* @return an {@link IntentFilter} for updates related to the {@link Slice} returned by
* {@link #getSlice()}.
*/
default IntentFilter getIntentFilter() {
return null;
}
/**
* Settings Slices which require background work, such as updating lists should implement a
* {@link SliceBackgroundWorker} and return it here. An example of background work is updating
@@ -116,12 +105,16 @@ public interface CustomSliceable {
PendingIntent.FLAG_CANCEL_CURRENT);
}
@Override
default boolean isSliceable() {
return true;
}
/**
* Build an instance of a {@link CustomSliceable} which has a {@link Context}-only constructor.
*/
static CustomSliceable createInstance(Context context, Class<CustomSliceable> sliceableClass) {
try {
//final Class<CustomSliceable> clazz = Class.forName(sliceableClassName);
final Constructor<CustomSliceable> sliceable =
sliceableClass.getConstructor(Context.class);
final Object[] params = new Object[]{context};