use of com.android.settingslib.core.lifecycle.LifecycleObserver in project android_packages_apps_Settings by LineageOS.
the class LanguageAndInputSettingsTest method testGetPreferenceControllers_shouldRegisterLifecycleObservers.
@Test
public void testGetPreferenceControllers_shouldRegisterLifecycleObservers() {
final List<AbstractPreferenceController> controllers = mFragment.getPreferenceControllers(mActivity);
int lifecycleObserverCount = 0;
for (AbstractPreferenceController controller : controllers) {
if (controller instanceof LifecycleObserver) {
lifecycleObserverCount++;
}
}
verify(mFragment.getLifecycle(), times(lifecycleObserverCount)).addObserver(any(LifecycleObserver.class));
}
use of com.android.settingslib.core.lifecycle.LifecycleObserver in project android_packages_apps_Settings by crdroidandroid.
the class LanguageAndInputSettingsTest method testGetPreferenceControllers_shouldRegisterLifecycleObservers.
@Test
public void testGetPreferenceControllers_shouldRegisterLifecycleObservers() {
final List<AbstractPreferenceController> controllers = mFragment.getPreferenceControllers(mActivity);
int lifecycleObserverCount = 0;
for (AbstractPreferenceController controller : controllers) {
if (controller instanceof LifecycleObserver) {
lifecycleObserverCount++;
}
}
verify(mFragment.getLifecycle(), times(lifecycleObserverCount)).addObserver(any(LifecycleObserver.class));
}
use of com.android.settingslib.core.lifecycle.LifecycleObserver in project platform_packages_apps_Settings by BlissRoms.
the class LanguageAndInputSettingsTest method testGetPreferenceControllers_shouldRegisterLifecycleObservers.
@Test
public void testGetPreferenceControllers_shouldRegisterLifecycleObservers() {
final List<AbstractPreferenceController> controllers = mFragment.getPreferenceControllers(mActivity);
int lifecycleObserverCount = 0;
for (AbstractPreferenceController controller : controllers) {
if (controller instanceof LifecycleObserver) {
lifecycleObserverCount++;
}
}
verify(mFragment.getLifecycle(), times(lifecycleObserverCount)).addObserver(any(LifecycleObserver.class));
}
use of com.android.settingslib.core.lifecycle.LifecycleObserver in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DashboardFragment method onAttach.
@Override
public void onAttach(Context context) {
super.onAttach(context);
mSuppressInjectedTileKeys = Arrays.asList(context.getResources().getStringArray(R.array.config_suppress_injected_tile_keys));
mDashboardFeatureProvider = FeatureFactory.getFactory(context).getDashboardFeatureProvider(context);
final List<AbstractPreferenceController> controllers = new ArrayList<>();
// Load preference controllers from code
final List<AbstractPreferenceController> controllersFromCode = createPreferenceControllers(context);
// Load preference controllers from xml definition
final List<BasePreferenceController> controllersFromXml = PreferenceControllerListHelper.getPreferenceControllersFromXml(context, getPreferenceScreenResId());
// Filter xml-based controllers in case a similar controller is created from code already.
final List<BasePreferenceController> uniqueControllerFromXml = PreferenceControllerListHelper.filterControllers(controllersFromXml, controllersFromCode);
// Add unique controllers to list.
if (controllersFromCode != null) {
controllers.addAll(controllersFromCode);
}
controllers.addAll(uniqueControllerFromXml);
// And wire up with lifecycle.
final Lifecycle lifecycle = getSettingsLifecycle();
uniqueControllerFromXml.stream().filter(controller -> controller instanceof LifecycleObserver).forEach(controller -> lifecycle.addObserver((LifecycleObserver) controller));
mPlaceholderPreferenceController = new DashboardTilePlaceholderPreferenceController(context);
controllers.add(mPlaceholderPreferenceController);
for (AbstractPreferenceController controller : controllers) {
addPreferenceController(controller);
}
checkUiBlocker(controllers);
}
use of com.android.settingslib.core.lifecycle.LifecycleObserver in project android_packages_apps_Settings by omnirom.
the class DashboardFragment method onAttach.
@Override
public void onAttach(Context context) {
super.onAttach(context);
mSuppressInjectedTileKeys = Arrays.asList(context.getResources().getStringArray(R.array.config_suppress_injected_tile_keys));
mDashboardFeatureProvider = FeatureFactory.getFactory(context).getDashboardFeatureProvider(context);
// Load preference controllers from code
final List<AbstractPreferenceController> controllersFromCode = createPreferenceControllers(context);
// Load preference controllers from xml definition
final List<BasePreferenceController> controllersFromXml = PreferenceControllerListHelper.getPreferenceControllersFromXml(context, getPreferenceScreenResId());
// Filter xml-based controllers in case a similar controller is created from code already.
final List<BasePreferenceController> uniqueControllerFromXml = PreferenceControllerListHelper.filterControllers(controllersFromXml, controllersFromCode);
// Add unique controllers to list.
if (controllersFromCode != null) {
mControllers.addAll(controllersFromCode);
}
mControllers.addAll(uniqueControllerFromXml);
// And wire up with lifecycle.
final Lifecycle lifecycle = getSettingsLifecycle();
uniqueControllerFromXml.forEach(controller -> {
if (controller instanceof LifecycleObserver) {
lifecycle.addObserver((LifecycleObserver) controller);
}
});
// Set metrics category for BasePreferenceController.
final int metricCategory = getMetricsCategory();
mControllers.forEach(controller -> {
if (controller instanceof BasePreferenceController) {
((BasePreferenceController) controller).setMetricsCategory(metricCategory);
}
});
mPlaceholderPreferenceController = new DashboardTilePlaceholderPreferenceController(context);
mControllers.add(mPlaceholderPreferenceController);
for (AbstractPreferenceController controller : mControllers) {
addPreferenceController(controller);
}
}
Aggregations