@Nullable @Override public String getTag(Fragment fragment) { return fragment.getTag(); }
public S hasTag(String tag) { isNotNull(); String actualTag = actual.getTag(); assertThat(actualTag).isEqualTo(tag); return myself; }
public LinkEvent(Fragment fragment, Link link, boolean wasCancelled) { mFragmentTag = fragment.getTag(); mLink = link; mWasCancelled = wasCancelled; }
public S hasTag(String tag) { isNotNull(); String actualTag = actual.getTag(); assertThat(actualTag).isEqualTo(tag); return myself; }
/** * Returns a tag of the currently showing fragment. <b>Note</b>, that this is only accurate, as * it depends on how are fragments changing, and if all fragments are managed by this controller. * * @return Tag of the currently showing fragment or {@code null} if no fragment was shown * by this controller yet. */ @Nullable public String getCurrentFragmentTag() { if (mFragmentContainerId > 0) { final Fragment fragment = mFragmentManager.findFragmentById(mFragmentContainerId); return fragment != null ? fragment.getTag() : null; } return null; }
/** * Shows the given <var>fragment</var> using the specified options. * * @param fragment The fragment instance to show. * @param options Options used by this controller to properly set up fragment transaction. * @return {@code True} if the fragment has been successfully shown, {@code false} * if there is already fragment with the same TAG already showing and should not be replaced. * @see #showFragment(Fragment) * @see #showFragment(Fragment, String) */ public boolean showFragment(@NonNull Fragment fragment, @Nullable FragmentTransactionOptions options) { final boolean success = onShowFragment(fragment, options); return success && notifyFragmentChanged(fragment.getId(), fragment.getTag(), false); }
/** * Creates a new instance of DialogController within the given <var>parentFragment</var>'s context. * <p> * Passed fragment will be used to obtain an instance of {@link android.app.FragmentManager} * by {@link android.app.Fragment#getFragmentManager()} that will be used to mange * dialog fragments by this controller. * <p> * If the given <var>parentFragment</var> implements {@link com.albedinsky.android.dialog.manage.DialogController.OnRestoreListener} * it will be automatically set as such a callback to this controller. * * @param parentFragment A fragment in which will be this controller used. * @see #DialogController(android.app.Activity) */ public DialogController(@NonNull Fragment parentFragment) { this(parentFragment.getFragmentManager()); if (parentFragment instanceof OnRestoreListener) { this.mRestoreListener = (OnRestoreListener) parentFragment; } this.mParentFragmentTag = parentFragment.getTag(); this.mParentFragmentId = parentFragment.getId(); }
/** * Creates a new instance of DialogController within the given <var>parentFragment</var>'s context. * <p> * Passed fragment will be used to obtain an instance of {@link android.app.FragmentManager} * by {@link android.app.Fragment#getFragmentManager()} that will be used to mange * dialog fragments by this controller. * <p> * If the given <var>parentFragment</var> implements {@link com.albedinsky.android.dialog.manage.DialogController.OnRestoreListener} * it will be automatically set as such a callback to this controller. * * @param parentFragment A fragment in which will be this controller used. * @see #DialogController(android.app.Activity) */ public DialogController(@NonNull Fragment parentFragment) { this(parentFragment.getFragmentManager()); if (parentFragment instanceof OnRestoreListener) { this.mRestoreListener = (OnRestoreListener) parentFragment; } this.mParentFragmentTag = parentFragment.getTag(); this.mParentFragmentId = parentFragment.getId(); }
/** * Performs showing of a fragment obtained from the current fragment factory. * * @param transactionOptions Options used when showing the requested fragment. * @return {@code True} if showing was successful, {@code false} otherwise. */ private boolean performShowFactoryFragment(FragmentTransactionOptions transactionOptions) { // First obtain fragment instance then fragment tag. Fragment fragment = mFactory.createFragmentInstance(transactionOptions); if (fragment == null) { // Invalid fragment instance. Log.e(TAG, "No fragment instance has been provided by the factory(" + mFactory.getClass().getSimpleName() + ") " + "for the requested incoming fragment id(" + transactionOptions.incomingFragmentId + ")."); return false; } final boolean success = onShowFragment(fragment, mFactory.configureTransactionOptions(transactionOptions)); return success && notifyFragmentChanged(transactionOptions.incomingFragmentId, fragment.getTag(), true); }
transaction.addToBackStack(fragment.getTag());
data.put("IDi", fragment.getId()); data.put("IDs", IdsHelper.getNameForId(fragment.getId())); data.put("Tag", fragment.getTag()); data.put("TargetFragment", fragment.getTargetFragment() != null ? String.valueOf(fragment.getTargetFragment()) : null); data.put("TargetRequestCode", fragment.getTargetRequestCode());
if (options.mAddToBackStack) { if (FragmentsConfig.DEBUG_LOG_ENABLED) { Log.d(TAG, "Fragment(" + fragment + ") added to back stack under the tag(" + fragment.getTag() + ").");