use of androidx.fragment.app.FragmentManager in project MTweaks-KernelAdiutorMOD by morogoku.
the class NavigationActivity method getFragment.
private Fragment getFragment(int res) {
FragmentManager fragmentManager = getSupportFragmentManager();
Fragment fragment = fragmentManager.findFragmentByTag(res + "_key");
if (fragment == null && mActualFragments.containsKey(res)) {
fragment = Fragment.instantiate(this, mActualFragments.get(res).getCanonicalName());
}
return fragment;
}
use of androidx.fragment.app.FragmentManager in project android_packages_apps_Settings by omnirom.
the class FingerprintErrorDialog method showErrorDialog.
public static void showErrorDialog(BiometricEnrollBase host, int errMsgId) {
final CharSequence errMsg = host.getText(getErrorMessage(errMsgId));
final FingerprintErrorDialog dialog = newInstance(errMsg, errMsgId);
final FragmentManager fragmentManager = host.getSupportFragmentManager();
if (!fragmentManager.isDestroyed()) {
dialog.show(fragmentManager, FingerprintErrorDialog.class.getName());
}
}
use of androidx.fragment.app.FragmentManager in project android_packages_apps_Settings by omnirom.
the class SettingsPanelActivity method createOrUpdatePanel.
private void createOrUpdatePanel(boolean shouldForceCreation) {
final Intent callingIntent = getIntent();
if (callingIntent == null) {
Log.e(TAG, "Null intent, closing Panel Activity");
finish();
return;
}
final String action = callingIntent.getAction();
// We will use it once media output switch panel support remote device.
final String mediaPackageName = callingIntent.getStringExtra(EXTRA_PACKAGE_NAME);
mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, action);
mBundle.putString(KEY_CALLING_PACKAGE_NAME, getCallingPackage());
mBundle.putString(KEY_MEDIA_PACKAGE_NAME, mediaPackageName);
final FragmentManager fragmentManager = getSupportFragmentManager();
final Fragment fragment = fragmentManager.findFragmentById(R.id.main_content);
// If fragment already exists and visible, we will need to update panel with animation.
if (!shouldForceCreation && fragment != null && fragment instanceof PanelFragment) {
mPanelFragment = (PanelFragment) fragment;
if (mPanelFragment.isPanelCreating()) {
Log.w(TAG, "A panel is creating, skip " + action);
return;
}
final Bundle bundle = fragment.getArguments();
if (bundle != null && TextUtils.equals(action, bundle.getString(KEY_PANEL_TYPE_ARGUMENT))) {
Log.w(TAG, "Panel is showing the same action, skip " + action);
return;
}
mPanelFragment.setArguments(new Bundle(mBundle));
mPanelFragment.updatePanelWithAnimation();
} else {
setContentView(R.layout.settings_panel);
// Move the window to the bottom of screen, and make it take up the entire screen width.
final Window window = getWindow();
window.setGravity(Gravity.BOTTOM);
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
mPanelFragment = new PanelFragment();
mPanelFragment.setArguments(new Bundle(mBundle));
fragmentManager.beginTransaction().add(R.id.main_content, mPanelFragment).commit();
}
}
use of androidx.fragment.app.FragmentManager in project android_packages_apps_Settings by omnirom.
the class SettingsActivityTest method onActivityResult_shouldDelegateToListener.
@Test
public void onActivityResult_shouldDelegateToListener() {
final List<Fragment> fragments = new ArrayList<>();
fragments.add(new Fragment());
fragments.add(new ListenerFragment());
final FragmentManager manager = mock(FragmentManager.class);
when(mActivity.getSupportFragmentManager()).thenReturn(manager);
when(manager.getFragments()).thenReturn(fragments);
mActivity.onActivityResult(0, 0, new Intent());
assertThat(((ListenerFragment) fragments.get(1)).mOnActivityResultCalled).isTrue();
}
use of androidx.fragment.app.FragmentManager in project BetterBatteryStats by asksven.
the class PermissionsFragmentActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// we need a layout to inflate the fragment into
FragmentManager fm = getSupportFragmentManager();
// Create the list fragment and add it as our sole content.
if (fm.findFragmentById(android.R.id.content) == null) {
PermissionsListFragment list = new PermissionsListFragment();
fm.beginTransaction().add(android.R.id.content, list).commit();
}
}
Aggregations