use of androidx.lifecycle.LifecycleObserver in project android_packages_apps_Settings by omnirom.
the class PanelFragment method createPanelContent.
private void createPanelContent() {
final FragmentActivity activity = getActivity();
if (activity == null) {
return;
}
if (mLayoutView == null) {
activity.finish();
return;
}
final ViewGroup.LayoutParams params = mLayoutView.getLayoutParams();
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
mLayoutView.setLayoutParams(params);
mPanelSlices = mLayoutView.findViewById(R.id.panel_parent_layout);
mSeeMoreButton = mLayoutView.findViewById(R.id.see_more);
mDoneButton = mLayoutView.findViewById(R.id.done);
mTitleView = mLayoutView.findViewById(R.id.panel_title);
mPanelHeader = mLayoutView.findViewById(R.id.panel_header);
mTitleIcon = mLayoutView.findViewById(R.id.title_icon);
mTitleGroup = mLayoutView.findViewById(R.id.title_group);
mHeaderLayout = mLayoutView.findViewById(R.id.header_layout);
mHeaderTitle = mLayoutView.findViewById(R.id.header_title);
mHeaderSubtitle = mLayoutView.findViewById(R.id.header_subtitle);
mFooterDivider = mLayoutView.findViewById(R.id.footer_divider);
mProgressBar = mLayoutView.findViewById(R.id.progress_bar);
mHeaderDivider = mLayoutView.findViewById(R.id.header_divider);
// Make the panel layout gone here, to avoid janky animation when updating from old panel.
// We will make it visible once the panel is ready to load.
mPanelSlices.setVisibility(View.GONE);
final Bundle arguments = getArguments();
final String callingPackageName = arguments.getString(SettingsPanelActivity.KEY_CALLING_PACKAGE_NAME);
mPanel = FeatureFactory.getFactory(activity).getPanelFeatureProvider().getPanel(activity, arguments);
if (mPanel == null) {
activity.finish();
return;
}
mPanel.registerCallback(new LocalPanelCallback());
if (mPanel instanceof LifecycleObserver) {
getLifecycle().addObserver((LifecycleObserver) mPanel);
}
mMetricsProvider = FeatureFactory.getFactory(activity).getMetricsFeatureProvider();
updateProgressBar();
mPanelSlices.setLayoutManager(new LinearLayoutManager((activity)));
// Add predraw listener to remove the animation and while we wait for Slices to load.
mLayoutView.getViewTreeObserver().addOnPreDrawListener(mOnPreDrawListener);
// Start loading Slices. When finished, the Panel will animate in.
loadAllSlices();
final IconCompat icon = mPanel.getIcon();
final CharSequence title = mPanel.getTitle();
final CharSequence subtitle = mPanel.getSubTitle();
if (icon != null || (subtitle != null && subtitle.length() > 0)) {
enablePanelHeader(icon, title, subtitle);
} else {
enableTitle(title);
}
mFooterDivider.setVisibility(View.GONE);
mSeeMoreButton.setOnClickListener(getSeeMoreListener());
mDoneButton.setOnClickListener(getCloseListener());
if (mPanel.isCustomizedButtonUsed()) {
enableCustomizedButton();
} else if (mPanel.getSeeMoreIntent() == null) {
// If getSeeMoreIntent() is null hide the mSeeMoreButton.
mSeeMoreButton.setVisibility(View.GONE);
}
// Log panel opened.
mMetricsProvider.action(0, /* attribution */
SettingsEnums.PAGE_VISIBLE, /* opened panel - Action */
mPanel.getMetricsCategory(), callingPackageName, 0);
}
use of androidx.lifecycle.LifecycleObserver in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class LanguageAndInputSettingsTest method testGetPreferenceControllers_shouldRegisterLifecycleObservers.
@Test
public void testGetPreferenceControllers_shouldRegisterLifecycleObservers() {
final List<AbstractPreferenceController> controllers = mFragment.createPreferenceControllers(mActivity);
int lifecycleObserverCount = 0;
for (AbstractPreferenceController controller : controllers) {
if (controller instanceof LifecycleObserver) {
lifecycleObserverCount++;
}
}
verify(mFragment.getSettingsLifecycle(), times(lifecycleObserverCount)).addObserver(any(LifecycleObserver.class));
}
use of androidx.lifecycle.LifecycleObserver in project android_packages_apps_Settings by omnirom.
the class LanguageAndInputSettingsTest method testGetPreferenceControllers_shouldRegisterLifecycleObservers.
@Test
public void testGetPreferenceControllers_shouldRegisterLifecycleObservers() {
final List<AbstractPreferenceController> controllers = mFragment.createPreferenceControllers(mActivity);
int lifecycleObserverCount = 0;
for (AbstractPreferenceController controller : controllers) {
if (controller instanceof LifecycleObserver) {
lifecycleObserverCount++;
}
}
verify(mFragment.getSettingsLifecycle(), times(lifecycleObserverCount)).addObserver(any(LifecycleObserver.class));
}
Aggregations