Java Code Examples for androidx.appcompat.app.AppCompatActivity#getSupportFragmentManager()

The following examples show how to use androidx.appcompat.app.AppCompatActivity#getSupportFragmentManager() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GDPR.java    From GDPRDialog with Apache License 2.0 6 votes vote down vote up
/**
 * shows the consent dialog
 *
 * @param activity the parent activity of the dialog
 * @param setup the setup for the dialog
 * @param location the request location
 */
public void showDialog(AppCompatActivity activity, GDPRSetup setup, GDPRLocation location) {
    FragmentManager fm = activity.getSupportFragmentManager();
    if (fm.findFragmentByTag(GDPRDialog.class.getName()) != null) {
        // dialog already exists, it either is already shown or will be shown automatically if activity is recreated
        return;
    }
    try {
        if (fm.isStateSaved()) {
            // in this case, activity will be destroyed, we ignore this call
            return;
        }
        showDialog(fm, activity, setup, location);
    } catch (NoSuchMethodError e) {
        // Support Library Version < 26.1.0 is used, isStateSaved is not yet existing...
        // we just catch the exception and ignore it
        try {
            showDialog(fm, activity, setup, location);
        } catch (IllegalStateException e2) {
            // ignored, activity is probably just being destroyed...
        }
    }
}
 
Example 2
Source File: ActivityUtils.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 6 votes vote down vote up
public static void startSearchDialog(AppCompatActivity activity, Bundle bundle) {
    if (UserManagerImpl.getInstance().getActiveUser() == null) {
        startLoginActivity(activity);
        return;
    }
    DialogFragment df = new SearchDialogFragment();
    df.setArguments(bundle);
    final String dialogTag = SearchDialogFragment.class.getSimpleName();
    FragmentManager fm = activity.getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag(dialogTag);
    if (prev != null) {
        ft.remove(prev);
    }
    try {
        df.show(ft, dialogTag);
    } catch (Exception e) {

    }
}
 
Example 3
Source File: ViewCheckInfoDokitView.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
private String getVisibleFragment(Activity activity) {
    if (activity == null) {
        return null;
    }
    StringBuilder builder = new StringBuilder();
    if (activity instanceof AppCompatActivity) {
        AppCompatActivity compatActivity = (AppCompatActivity) activity;
        FragmentManager fragmentManager = compatActivity.getSupportFragmentManager();
        List<Fragment> fragments = fragmentManager.getFragments();
        if (fragments != null && fragments.size() != 0) {
            for (int i = 0; i < fragments.size(); i++) {
                Fragment fragment = fragments.get(i);
                if (fragment != null && fragment.isVisible()) {
                    builder.append(fragment.getClass().getSimpleName() + "#" + fragment.getId());
                    if (i < fragments.size() - 1) {
                        builder.append(";");
                    }
                }
            }
            return builder.toString();
        } else {
            return getFragmentForActivity(activity);
        }
    } else {
        return getFragmentForActivity(activity);
    }
}
 
Example 4
Source File: IntroController.java    From MusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
private void initBackStack(AppCompatActivity activity, Bundle savedInstanceState) {
    FragmentManager fm = activity.getSupportFragmentManager();
    mNavigationController = FragmentNavigationController.navigationController(fm, R.id.back_wall_container);
    mNavigationController.setAbleToPopRoot(true);
    mNavigationController.setPresentStyle(PRESENT_STYLE_DEFAULT);
    mNavigationController.setDuration(250);
    mNavigationController.setInterpolator(new AccelerateDecelerateInterpolator());
    mNavigationController.presentFragment(new IntroStepOneFragment());
    // mNavigationController.presentFragment(new MainFragment());
}
 
Example 5
Source File: MaterialDatePickerTestUtils.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
public static <S> MaterialDatePicker<S> buildAndShow(
    AppCompatActivity activity, MaterialDatePicker.Builder<S> builder) {
  FragmentManager fragmentManager = activity.getSupportFragmentManager();
  String tag = "DialogFragment";
  MaterialDatePicker<S> dialogFragment = builder.build();
  dialogFragment.show(fragmentManager, tag);
  InstrumentationRegistry.getInstrumentation().waitForIdleSync();
  return dialogFragment;
}
 
Example 6
Source File: AlAttachmentOptions.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void processAudioAction(AppCompatActivity activity, LinearLayout layout) {
    if (Utils.hasMarshmallow() && PermissionsUtils.checkSelfPermissionForAudioRecording(activity)) {
        new ApplozicPermissions(activity, layout).requestAudio();
    } else if (PermissionsUtils.isAudioRecordingPermissionGranted(activity)) {
        FragmentManager supportFragmentManager = activity.getSupportFragmentManager();
        DialogFragment fragment = AudioMessageFragment.newInstance();
        FragmentTransaction fragmentTransaction = supportFragmentManager
                .beginTransaction().add(fragment, "AudioMessageFragment");

        fragmentTransaction.addToBackStack(null);
        fragmentTransaction.commitAllowingStateLoss();
    } else {
        //Permissions not granted error
    }
}
 
Example 7
Source File: ActivityStarter.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
@Override
public FragmentManager getSupportFragmentManager() {
    if (context instanceof AppCompatActivity) {
        AppCompatActivity activity = (AppCompatActivity) context;
        activity.getSupportFragmentManager();
    }
    return null;
}
 
Example 8
Source File: FragmentsAdapter.java    From adamant-android with GNU General Public License v3.0 4 votes vote down vote up
public FragmentsAdapter(AppCompatActivity context, List<FragmentClassHolder> holders) {
    super(context.getSupportFragmentManager());

    this.holders = holders;
    this.context = context;
}
 
Example 9
Source File: SearchPreferenceResult.java    From SearchPreference with MIT License 4 votes vote down vote up
/**
 * Closes the search results page
 * @param activity The current activity
 */
public void closeSearchPage(AppCompatActivity activity) {
    FragmentManager fm = activity.getSupportFragmentManager();
    fm.beginTransaction().remove(fm.findFragmentByTag(SearchPreferenceFragment.NAME)).commit();
}
 
Example 10
Source File: FileSelectorDialog.java    From HaoReader with GNU General Public License v3.0 4 votes vote down vote up
public void show(AppCompatActivity activity, OnFileSelectedListener selectedListener) {
    this.selectedListener = selectedListener;
    super.show(activity.getSupportFragmentManager(), "FileSelectorDialog");
}
 
Example 11
Source File: ProgressDialog.java    From HaoReader with GNU General Public License v3.0 4 votes vote down vote up
public void show(AppCompatActivity activity) {
    if (!isShowing() && activity != null) {
        super.show(activity.getSupportFragmentManager(), "waiting");
    }
}
 
Example 12
Source File: UIRouter.java    From RendererRecyclerViewAdapter with Apache License 2.0 4 votes vote down vote up
public UIRouter(@NonNull final AppCompatActivity activity) {
	mContext = activity;
	mFragmentManager = activity.getSupportFragmentManager();
}
 
Example 13
Source File: NumberPickerDialogFragment.java    From Jockey with Apache License 2.0 4 votes vote down vote up
public Builder(AppCompatActivity activity) {
    mFragmentManager = activity.getSupportFragmentManager();
    mTargetFragment = null;
}
 
Example 14
Source File: DurationPickerDialogFragment.java    From Jockey with Apache License 2.0 4 votes vote down vote up
public Builder(AppCompatActivity activity) {
    mFragmentManager = activity.getSupportFragmentManager();
    mTargetFragment = null;
}
 
Example 15
Source File: AppendPlaylistDialogFragment.java    From Jockey with Apache License 2.0 4 votes vote down vote up
public Builder(AppCompatActivity activity) {
    this(activity, activity.getSupportFragmentManager());
}