androidx.fragment.app.Fragment Java Examples

The following examples show how to use androidx.fragment.app.Fragment. 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 Project: cathode   Author: SimonVT   File: FragmentStack.java    License: Apache License 2.0 6 votes vote down vote up
/** Removes all added fragments and clears the stack. */
public void destroy() {
  if (!allowTransactions()) {
    return;
  }

  commit();

  ensureTransaction();
  fragmentTransaction.setCustomAnimations(enterAnimation, exitAnimation);

  final Fragment topFragment = stack.peekFirst();
  for (Fragment f : stack) {
    if (f != topFragment) removeFragment(f);
  }
  stack.clear();

  for (String tag : topLevelTags) {
    removeFragment(fragmentManager.findFragmentByTag(tag));
  }

  fragmentTransaction.commitNow();
  fragmentTransaction = null;
}
 
Example #2
Source Project: materialistic   Author: hidroh   File: ItemPagerAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Fragment getItem(int position) {
    if (mFragments[position] != null) {
        return mFragments[position];
    }
    String fragmentName;
    Bundle args = new Bundle();
    args.putBoolean(LazyLoadFragment.EXTRA_EAGER_LOAD, mDefaultItem == position);
    if (position == 0) {
        args.putParcelable(ItemFragment.EXTRA_ITEM, mItem);
        args.putInt(ItemFragment.EXTRA_CACHE_MODE, mCacheMode);
        args.putBoolean(ItemFragment.EXTRA_RETAIN_INSTANCE, mRetainInstance);
        fragmentName = ItemFragment.class.getName();
    } else {
        args.putParcelable(WebFragment.EXTRA_ITEM, mItem);
        args.putBoolean(WebFragment.EXTRA_RETAIN_INSTANCE, mRetainInstance);
        fragmentName = WebFragment.class.getName();
    }
    return Fragment.instantiate(mContext, fragmentName, args);
}
 
Example #3
Source Project: DeviceConnect-Android   Author: DeviceConnect   File: ConfirmationDialogFragment.java    License: MIT License 6 votes vote down vote up
public static ConfirmationDialogFragment newInstance(
        final String title, final String message, final String positive,
        final String negative, final Fragment fragment) {
    Bundle args = new Bundle();
    args.putString(EXTRA_TITLE, title);
    args.putString(EXTRA_MESSAGE, message);
    if (positive != null) {
        args.putString(EXTRA_POSITIVE, positive);
    }
    if (negative != null) {
        args.putString(EXTRA_NEGATIVE, negative);
    }

    ConfirmationDialogFragment f = new ConfirmationDialogFragment();
    f.setArguments(args);
    if (fragment != null) {
        f.setTargetFragment(fragment, 0);
    }
    return f;
}
 
Example #4
Source Project: simple-stack   Author: Zhuinden   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
public void setupViewsForKey(BaseKey key) {
    if(key.shouldShowUp()) {
        drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED, GravityCompat.START);
        drawerToggle.setDrawerIndicatorEnabled(false);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    } else {
        drawerLayout.setDrawerLockMode(LOCK_MODE_UNLOCKED, GravityCompat.START);
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        drawerToggle.setDrawerIndicatorEnabled(true);
    }
    drawerToggle.syncState();
    setCheckedItem(key.navigationViewId());
    supportInvalidateOptionsMenu();
    if(key.isFabVisible()) {
        fab.show();
    } else {
        fab.hide();
    }
    Fragment fragment = getSupportFragmentManager().findFragmentByTag(key.getFragmentTag());
    key.setupFab(fragment, fab);
}
 
Example #5
Source Project: PresencePublisher   Author: ostrya   File: AddBeaconChoicePreferenceDummy.java    License: MIT License 6 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public AddBeaconChoicePreferenceDummy(Context context, Fragment fragment) {
    super(context);
    setKey(DUMMY);
    setIcon(android.R.drawable.ic_menu_add);
    setTitle(R.string.add_beacon_title);
    setSummary(R.string.add_beacon_summary);
    setOnPreferenceClickListener(prefs -> {
        BluetoothManager bluetoothManager = (BluetoothManager) getContext().getSystemService(Context.BLUETOOTH_SERVICE);
        if (bluetoothManager == null) {
            HyperLog.w(TAG, "Unable to get bluetooth manager");
        } else {
            BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
            if (bluetoothAdapter == null || !bluetoothAdapter.isEnabled()) {
                Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
                fragment.startActivityForResult(enableBtIntent, ON_DEMAND_BLUETOOTH_REQUEST_CODE);
                return true;
            }
        }
        BeaconScanDialogFragment instance = getInstance(getContext(), this::onScanResult,
                getSharedPreferences().getStringSet(BEACON_LIST, Collections.emptySet()));
        instance.show(fragment.requireFragmentManager(), null);
        return true;
    });
}
 
Example #6
Source Project: AndroidQuick   Author: ddnosh   File: EasyPermissions.java    License: MIT License 6 votes vote down vote up
private static void checkCallingObjectSuitability(Object object) {
    // Make sure Object is an Activity or Fragment
    boolean isActivity = object instanceof Activity;
    boolean isSupportFragment = object instanceof Fragment;
    boolean isAppFragment = object instanceof android.app.Fragment;
    boolean isMinSdkM = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;

    if (!(isSupportFragment || isActivity || (isAppFragment && isMinSdkM))) {
        if (isAppFragment) {
            throw new IllegalArgumentException(
                    "Target SDK needs to be greater than 23 if caller is android.app.Fragment");
        } else {
            throw new IllegalArgumentException("Caller must be an Activity or a Fragment.");
        }
    }
}
 
Example #7
Source Project: AndroidNavigation   Author: listenzz   File: AwesomeFragment.java    License: MIT License 6 votes vote down vote up
private void handleHideBottomBarWhenPushed(int transit, boolean enter, PresentAnimation animation) {
    // handle hidesBottomBarWhenPushed
    Fragment parent = getParentFragment();
    if (parent instanceof NavigationFragment) {
        NavigationFragment navigationFragment = (NavigationFragment) parent;
        TabBarFragment tabBarFragment = navigationFragment.getTabBarFragment();
        if (tabBarFragment == null || !enter) {
            return;
        }

        int index = getIndexAtBackStack();
        if (transit == FragmentTransaction.TRANSIT_FRAGMENT_OPEN) {
            if (index == 0) {
                if (tabBarFragment.getTabBar() != null) {
                    tabBarFragment.showTabBarWhenPop(R.anim.nav_none);
                }
            } else if (index == 1 && shouldHideTabBarWhenPushed()) {
                tabBarFragment.hideTabBarWhenPush(animation.exit);
            }
        } else if (transit == FragmentTransaction.TRANSIT_FRAGMENT_CLOSE) {
            if (index == 0 && shouldHideTabBarWhenPushed()) {
                tabBarFragment.showTabBarWhenPop(animation.popEnter);
            }
        }
    }
}
 
Example #8
Source Project: EdXposedManager   Author: ElderDrivers   File: WelcomeActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void notifyDataSetChanged() {
    View parentLayout = findViewById(R.id.content_frame);
    String frameworkUpdateVersion = mRepoLoader.getFrameworkUpdateVersion();
    boolean moduleUpdateAvailable = mRepoLoader.hasModuleUpdates();

    Fragment currentFragment = getSupportFragmentManager()
            .findFragmentById(R.id.content_frame);
    if (currentFragment instanceof DownloadDetailsFragment) {
        if (frameworkUpdateVersion != null) {
            Snackbar.make(parentLayout, R.string.welcome_framework_update_available + " " + frameworkUpdateVersion, Snackbar.LENGTH_LONG).show();
        }
    }

    boolean snackBar = getSharedPreferences(
            getPackageName() + "_preferences", MODE_PRIVATE).getBoolean("snack_bar", true);

    if (moduleUpdateAvailable && snackBar) {
        Snackbar.make(parentLayout, R.string.modules_updates_available, Snackbar.LENGTH_LONG).setAction(getString(R.string.view), view -> switchFragment(4)).show();
    }
}
 
Example #9
Source Project: libcommon   Author: saki4510t   File: ConfirmDialogV4.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * ダイアログ表示のためのヘルパーメソッド
 * こっちはCharSequenceとしてメッセージ内容を指定
 * @param parent
 * @param requestCode
 * @param id_title
 * @param message
 * @param canceledOnTouchOutside
 * @param userArgs
 * @return
 * @throws IllegalStateException
 */
public static ConfirmDialogV4 showDialog(
	@NonNull final Fragment parent, final int requestCode,
	@StringRes final int id_title, @NonNull final CharSequence message,
	final boolean canceledOnTouchOutside,
	@Nullable final Bundle userArgs) throws IllegalStateException {

	final ConfirmDialogV4 dialog
		= newInstance(requestCode,
			id_title, 0, message,
			canceledOnTouchOutside,
			userArgs);
	dialog.setTargetFragment(parent, parent.getId());
	dialog.show(parent.getParentFragmentManager(), TAG);
	return dialog;
}
 
Example #10
Source Project: arcusandroid   Author: arcus-smart-home   File: SettingsPlaceFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override public boolean onOptionsItemSelected(@NonNull MenuItem item) {
    // If we're currently saving data - don't do anything.
    if (isSaving.get()) {
        return true;
    }

    // Don't do anything if we're showing the tz fragment.
    Fragment tzFragment = BackstackManager.getInstance().getFragmentOnStack(TimezonePickerPopup.class);
    if (tzFragment != null && tzFragment instanceof TimezonePickerPopup && tzFragment.isVisible()) {
        return true;
    }

    // If for some reason we clicked on something that shouldn't be there....
    if (item.getItemId() != R.id.menu_edit_contact) {
        return super.onOptionsItemSelected(item);
    }

    // Else update the editing/not editing mode.
    String menuTitle = String.valueOf(item.getTitle());
    boolean editing = edit.equalsIgnoreCase(menuTitle);
    item.setTitle(editing ? done : edit);
    enableInput(editing);

    return true;
}
 
Example #11
Source Project: libcommon   Author: saki4510t   File: MessageDialogFragmentV4.java    License: Apache License 2.0 6 votes vote down vote up
@Override
	public void onAttach(@NonNull final Context context) {
		super.onAttach(context);
		// コールバックインターフェースを取得
		if (context instanceof MessageDialogListener) {
			mDialogListener = (MessageDialogListener)context;
		}
		if (mDialogListener == null) {
			final Fragment fragment = getTargetFragment();
			if (fragment instanceof MessageDialogListener) {
				mDialogListener = (MessageDialogListener)fragment;
			}
		}
		if (mDialogListener == null) {
			if (BuildCheck.isAndroid4_2()) {
				final Fragment target = getParentFragment();
				if (target instanceof MessageDialogListener) {
					mDialogListener = (MessageDialogListener)target;
				}
			}
		}
		if (mDialogListener == null) {
//			Log.w(TAG, "caller activity/fragment must implement PermissionDetailDialogFragmentListener");
        	throw new ClassCastException(context.toString());
		}
	}
 
Example #12
Source Project: Notepad   Author: farmerbb   File: WelcomeFragment.java    License: Apache License 2.0 6 votes vote down vote up
public void dispatchKeyShortcutEvent(int keyCode) {
    switch(keyCode) {
            // CTRL+N: New Note
        case KeyEvent.KEYCODE_N:
            Bundle bundle = new Bundle();
            bundle.putString("filename", "new");

            Fragment fragment = new NoteEditFragment();
            fragment.setArguments(bundle);

            // Add NoteEditFragment
            getFragmentManager()
                .beginTransaction()
                .replace(R.id.noteViewEdit, fragment, "NoteEditFragment")
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
                .commit();
            break;
    }
}
 
Example #13
Source Project: Moneycim   Author: volkansahin45   File: MainActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    unbinder = ButterKnife.bind(this);

    setSupportActionBar(toolbar);

    if(savedInstanceState == null){
        showRootFragment(SpendingListFragment.newInstance());
    }

    fragmentManager.addOnBackStackChangedListener(() -> {
        List<Fragment> fragments = fragmentManager.getFragments();
        Fragment lastFragment = fragments.get(fragments.size() - 1);

        if(lastFragment instanceof SpendingListFragment){
            appBarLayout.setExpanded(true);
            fab.show();
        } else {
            appBarLayout.setExpanded(false);
            fab.hide();
        }
    });
}
 
Example #14
Source Project: Field-Book   Author: PhenoApps   File: PreferencesActivity.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onPreferenceStartFragment(PreferenceFragmentCompat caller, androidx.preference.Preference pref) {

    // Instantiate the new Fragment
    final Bundle args = pref.getExtras();
    final Fragment fragment = getSupportFragmentManager().getFragmentFactory().instantiate(
            getClassLoader(),
            pref.getFragment());
    fragment.setArguments(args);
    fragment.setTargetFragment(caller, 0);

    // Replace the existing Fragment with the new Fragment
    getSupportFragmentManager().beginTransaction()
            .replace(android.R.id.content, fragment)
            .addToBackStack(null)
            .commit();
    return true;
}
 
Example #15
Source Project: bottomsheets   Author: arthur3486   File: CustomActionPickerBottomSheet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance of the {@link CustomActionPickerBottomSheet} for the specified custom items.
 *
 * @param fragment the host fragment
 * @param items the custom action items
 * @param config the sheet configuration
 * @return the created {@link CustomActionPickerBottomSheet}
 */
@NonNull
public static <IT extends BaseActionItem> CustomActionPickerBottomSheet<IT> init(@NonNull Fragment fragment,
                                                                                 @NonNull List<IT> items,
                                                                                 @NonNull ActionPickerConfig config) {
    Preconditions.nonNull(fragment);
    Preconditions.nonNull(fragment.getActivity());
    Preconditions.nonNull(items);
    Preconditions.nonNull(config);

    return init(
        fragment.getActivity(),
        items,
        new ActionPickerItemResources(),
        config
    );
}
 
Example #16
Source Project: CalendarView   Author: huanghaibin-dev   File: FragmentAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
    if (mUpdateFlag) {
        Fragment fragment = (Fragment) super.instantiateItem(container, position);
        String tag = fragment.getTag();
        FragmentTransaction transaction = mFragmentManager.beginTransaction();
        transaction.remove(fragment);
        fragment = getItem(position);
        if (!fragment.isAdded()) {
            transaction.add(container.getId(), fragment, tag)
                    .attach(fragment)
                    .commitAllowingStateLoss();
        }
        return fragment;
    }
    return super.instantiateItem(container, position);
}
 
Example #17
Source Project: RxLifecycle   Author: trello   File: RxPreferenceFragmentLifecycleTest.java    License: Apache License 2.0 6 votes vote down vote up
private void testBindUntilEvent(LifecycleProvider<FragmentEvent> provider) {
    Fragment fragment = (Fragment) provider;
    startFragment(fragment);

    TestObserver<Object> testObserver = observable.compose(provider.bindUntilEvent(STOP)).test();

    fragment.onAttach(null);
    testObserver.assertNotComplete();
    fragment.onCreate(null);
    testObserver.assertNotComplete();
    fragment.onViewCreated(null, null);
    testObserver.assertNotComplete();
    fragment.onStart();
    testObserver.assertNotComplete();
    fragment.onResume();
    testObserver.assertNotComplete();
    fragment.onPause();
    testObserver.assertNotComplete();
    fragment.onStop();
    testObserver.assertComplete();
}
 
Example #18
Source Project: MHViewer   Author: axlecho   File: EnterGalleryDetailTransaction.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean onTransition(Context context, FragmentTransaction transaction,
        Fragment exit, Fragment enter) {
    if (mThumb == null || !(enter instanceof GalleryDetailScene)) {
        return false;
    }

    String transitionName = ViewCompat.getTransitionName(mThumb);
    if (transitionName != null) {
        exit.setSharedElementReturnTransition(
                TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
        exit.setExitTransition(
                TransitionInflater.from(context).inflateTransition(R.transition.trans_fade));
        enter.setSharedElementEnterTransition(
                TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
        enter.setEnterTransition(
                TransitionInflater.from(context).inflateTransition(R.transition.trans_fade));
        transaction.addSharedElement(mThumb, transitionName);
    }
    return true;
}
 
Example #19
Source Project: HaoReader   Author: Invinciblelee   File: FileSelectorPresenterImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init(Fragment fragment) {
    Bundle bundle = fragment.getArguments();
    assert bundle != null;
    title = bundle.getString("title");
    isSingleChoice = bundle.getBoolean("isSingleChoice");
    checkBookAdded = bundle.getBoolean("checkBookAdded");
    isImage = bundle.getBoolean("isImage");
    ArrayList<String> list = bundle.getStringArrayList("suffixes");
    assert list != null;
    suffixes = new String[list.size()];
    list.toArray(suffixes);
    key = StringUtils.join(",", list);
}
 
Example #20
Source Project: live-app-android   Author: hypertrack   File: WelcomeFragment.java    License: MIT License 5 votes vote down vote up
public static Fragment newInstance(String pubKey) {
    WelcomeFragment fragment = new WelcomeFragment();
    Bundle bundle = new Bundle();
    bundle.putString(MainActivity.PUBLISHABLE_KEY, pubKey);
    fragment.setArguments(bundle);
    return fragment;
}
 
Example #21
Source Project: PresencePublisher   Author: ostrya   File: BeaconPreference.java    License: MIT License 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public BeaconPreference(Context context, String beaconId, Fragment fragment) {
    super(context, BEACON_CONTENT_PREFIX + beaconId, new RegexValidator(".+"), beaconId);
    this.beaconId = beaconId;
    this.fragment = fragment;
    setDefaultValue(DEFAULT_CONTENT_ONLINE);
    // order alphabetically
    setOrder(0);
}
 
Example #22
Source Project: arcusandroid   Author: arcus-smart-home   File: DashboardActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void popOverlay(Fragment frag) {
    if(frag != null) {
        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction trans = manager.beginTransaction();
        trans.remove(frag);
        trans.commit();
        manager.popBackStack();
    }
}
 
Example #23
Source Project: arcusandroid   Author: arcus-smart-home   File: FullscreenFragmentActivity.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressLint("SourceLockedOrientationActivity")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fullscreen_error);
    Integer orientation = getIntent().getIntExtra(FRAGMENT_ORIENTATION, -1);
    if (orientation != -1) {
        if (orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    }

    try {
        // Get an instance of the requested fragment...
        Class<? extends Fragment> fragmentClass = (Class) getIntent().getSerializableExtra(FRAGMENT_CLASS);
        Fragment fragmentInstance = fragmentClass.newInstance();
        Bundle arguments = getIntent().getBundleExtra(FRAGMENT_ARGUMENTS);
        if (arguments != null) {
            fragmentInstance.setArguments(arguments);
        }

        // ... and insert it into the activity
        getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, fragmentInstance).commit();
    }

    // If anything goes wrong, return the user to the previous activity
    catch (Exception e) {
        finish();
    }
}
 
Example #24
Source Project: itag   Author: s4ysolutions   File: FragmentsSelectTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void bleTurnedOn_shouldReturnITagsFragment() {
    mockBluetoothAdapter =  Mockito.mock(BluetoothAdapter.class);
    when(mockBluetoothAdapter.isEnabled())
            .thenReturn(false) //disabled
            .thenReturn(true); // turned on
    when(mockBluetoothManager.getAdapter()).thenReturn(mockBluetoothAdapter);
    MainActivity mainActivity = Robolectric.setupActivity(MainActivity.class);
    final FragmentManager fragmentManager = mainActivity.getSupportFragmentManager();
    Fragment fragment = fragmentManager.findFragmentById(R.id.content);
    Assert.assertTrue(fragment instanceof ITagsFragment);
}
 
Example #25
Source Project: geopaparazzi   Author: geopaparazzi   File: FormActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onSaveInstanceState(Bundle outState) {
    try {
        Fragment detailFragment = getSupportFragmentManager().findFragmentById(R.id.detailFragment);
        if (detailFragment instanceof FormDetailFragment) {
            FormDetailFragment fdFragment = (FormDetailFragment) detailFragment;
            fdFragment.storeFormItems(false);

            FormInfoHolder formInfo = fdFragment.getFormInfoHolder();
            sectionObject = new JSONObject(formInfo.sectionObjectString);


            FormInfoHolder formInfoHolder = new FormInfoHolder();
            formInfoHolder.sectionName = mSectionName;
            formInfoHolder.formName = mFormName;
            formInfoHolder.sectionObjectString = sectionObject.toString();
            formInfoHolder.noteId = noteId;
            formInfoHolder.longitude = longitude;
            formInfoHolder.latitude = latitude;
            formInfoHolder.objectExists = !noteIsNew;

            outState.putSerializable(FormInfoHolder.BUNDLE_KEY_INFOHOLDER, formInfoHolder);
        }
    } catch (Exception e) {
        GPLog.error(this, null, e);
    }

    super.onSaveInstanceState(outState);
}
 
Example #26
Source Project: aptoide-client-v8   Author: Aptoide   File: VanillaFragmentProvider.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override public Fragment newAppViewFragment(long appId, String packageName, String storeTheme,
    String storeName, String tag) {
  Bundle bundle = new Bundle();
  bundle.putString(AppViewFragment.BundleKeys.ORIGIN_TAG.name(), tag);
  bundle.putLong(AppViewFragment.BundleKeys.APP_ID.name(), appId);
  bundle.putString(AppViewFragment.BundleKeys.PACKAGE_NAME.name(), packageName);
  bundle.putString(AppViewFragment.BundleKeys.STORE_NAME.name(), storeName);
  bundle.putString(AppViewFragment.BundleKeys.STORE_THEME.name(), storeTheme);
  AppViewFragment fragment = new AppViewFragment();
  fragment.setArguments(bundle);
  return fragment;
}
 
Example #27
Source Project: AndroidQuick   Author: ddnosh   File: CodeAndRunActivity.java    License: MIT License 5 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    Fragment prev = getSupportFragmentManager().findFragmentByTag("BottomDialogFragment");
    if (prev != null) {
        DialogFragment df = (DialogFragment) prev;
        df.dismiss();
    }
}
 
Example #28
Source Project: J2ME-Loader   Author: nikita36078   File: DonationsActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	super.onActivityResult(requestCode, resultCode, data);

	FragmentManager fragmentManager = getSupportFragmentManager();
	Fragment fragment = fragmentManager.findFragmentByTag("donationsFragment");
	if (fragment != null) {
		fragment.onActivityResult(requestCode, resultCode, data);
	}
}
 
Example #29
Source Project: material-components-android   Author: material-components   File: RadioButtonFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Demo getMainDemo() {
  return new Demo() {
    @Override
    public Fragment createFragment() {
      return new RadioButtonMainDemoFragment();
    }
  };
}
 
Example #30
Source Project: arcusandroid   Author: arcus-smart-home   File: StepsViewPagerAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
    Object object = super.instantiateItem(container, position);
    if(object instanceof Fragment){
        //record fragment tag here
        Fragment f = (Fragment) object;
        String tag = f.getTag();
        fragmentTags.put(position, tag);
    }
    return object;
}