Search in sources :

Example 61 with FragmentManager

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;
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) LMKFragment(com.moro.mtweaks.fragments.kernel.LMKFragment) BackupFragment(com.moro.mtweaks.fragments.tools.BackupFragment) BuildpropFragment(com.moro.mtweaks.fragments.tools.BuildpropFragment) Fragment(androidx.fragment.app.Fragment) BusDispFragment(com.moro.mtweaks.fragments.kernel.BusDispFragment) WakeFragment(com.moro.mtweaks.fragments.kernel.WakeFragment) ThermalFragment(com.moro.mtweaks.fragments.kernel.ThermalFragment) EntropyFragment(com.moro.mtweaks.fragments.kernel.EntropyFragment) OverallFragment(com.moro.mtweaks.fragments.statistics.OverallFragment) CPUVoltageCl0Fragment(com.moro.mtweaks.fragments.kernel.CPUVoltageCl0Fragment) ScreenFragment(com.moro.mtweaks.fragments.kernel.ScreenFragment) LEDFragment(com.moro.mtweaks.fragments.kernel.LEDFragment) CPUFragment(com.moro.mtweaks.fragments.kernel.CPUFragment) DeviceFragment(com.moro.mtweaks.fragments.statistics.DeviceFragment) MemoryFragment(com.moro.mtweaks.fragments.statistics.MemoryFragment) AboutFragment(com.moro.mtweaks.fragments.other.AboutFragment) InitdFragment(com.moro.mtweaks.fragments.tools.InitdFragment) RecoveryFragment(com.moro.mtweaks.fragments.tools.RecoveryFragment) WakelockFragment(com.moro.mtweaks.fragments.kernel.WakelockFragment) CPUVoltageCl1Fragment(com.moro.mtweaks.fragments.kernel.CPUVoltageCl1Fragment) SoundFragment(com.moro.mtweaks.fragments.kernel.SoundFragment) IOFragment(com.moro.mtweaks.fragments.kernel.IOFragment) DvfsFragment(com.moro.mtweaks.fragments.kernel.DvfsFragment) SpectrumFragment(com.moro.mtweaks.fragments.kernel.SpectrumFragment) MiscFragment(com.moro.mtweaks.fragments.kernel.MiscFragment) SettingsFragment(com.moro.mtweaks.fragments.other.SettingsFragment) CustomControlsFragment(com.moro.mtweaks.fragments.tools.customcontrols.CustomControlsFragment) BoefflaWakelockFragment(com.moro.mtweaks.fragments.kernel.BoefflaWakelockFragment) ProfileFragment(com.moro.mtweaks.fragments.tools.ProfileFragment) GPUFragment(com.moro.mtweaks.fragments.kernel.GPUFragment) BusMifFragment(com.moro.mtweaks.fragments.kernel.BusMifFragment) VMFragment(com.moro.mtweaks.fragments.kernel.VMFragment) DownloadsFragment(com.moro.mtweaks.fragments.tools.downloads.DownloadsFragment) DonationFragment(com.moro.mtweaks.fragments.other.DonationFragment) BaseFragment(com.moro.mtweaks.fragments.BaseFragment) BusCamFragment(com.moro.mtweaks.fragments.kernel.BusCamFragment) KSMFragment(com.moro.mtweaks.fragments.kernel.KSMFragment) BatteryFragment(com.moro.mtweaks.fragments.kernel.BatteryFragment) InputsFragment(com.moro.mtweaks.fragments.statistics.InputsFragment) HmpFragment(com.moro.mtweaks.fragments.kernel.HmpFragment) OnBootFragment(com.moro.mtweaks.fragments.tools.OnBootFragment) BusIntFragment(com.moro.mtweaks.fragments.kernel.BusIntFragment) CPUHotplugFragment(com.moro.mtweaks.fragments.kernel.CPUHotplugFragment)

Example 62 with FragmentManager

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());
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager)

Example 63 with FragmentManager

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();
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) Window(android.view.Window) Bundle(android.os.Bundle) Intent(android.content.Intent) Fragment(androidx.fragment.app.Fragment)

Example 64 with FragmentManager

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();
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) ArrayList(java.util.ArrayList) Intent(android.content.Intent) Fragment(androidx.fragment.app.Fragment) Test(org.junit.Test)

Example 65 with FragmentManager

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();
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager)

Aggregations

FragmentManager (androidx.fragment.app.FragmentManager)163 FragmentTransaction (androidx.fragment.app.FragmentTransaction)55 Fragment (androidx.fragment.app.Fragment)42 Bundle (android.os.Bundle)28 Test (org.junit.Test)15 Intent (android.content.Intent)13 FragmentActivity (androidx.fragment.app.FragmentActivity)10 Activity (android.app.Activity)6 View (android.view.View)6 DialogFragment (androidx.fragment.app.DialogFragment)6 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)5 Context (android.content.Context)4 DialogInterface (android.content.DialogInterface)3 LayoutInflater (android.view.LayoutInflater)3 MenuInflater (android.view.MenuInflater)3 Window (android.view.Window)3 TextView (android.widget.TextView)3 AlertDialog (androidx.appcompat.app.AlertDialog)3 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)3 ViewModelProvider (androidx.lifecycle.ViewModelProvider)3