@@ -0,0 +1,2920 @@
+package com.stolets.rxdiffutil.util;%0A%0Aimport android.app.Fragment;%0Aimport android.app.FragmentManager;%0Aimport android.app.FragmentTransaction;%0Aimport android.support.annotation.NonNull;%0A%0Aimport com.stolets.rxdiffutil.diffrequest.DiffRequestManagerFragment;%0A%0Aimport static com.stolets.rxdiffutil.internal.Preconditions.checkArgument;%0Aimport static com.stolets.rxdiffutil.internal.Preconditions.checkNotNull;%0A%0Apublic final class ActivityUtils %7B%0A    /**%0A     * The %7B@code fragment%7D is added to the container view with id %7B@code frameId%7D. The operation is%0A     * performed by the %7B@code fragmentManager%7D.%0A     *%0A     */%0A    static void addFragmentToActivity (@NonNull final FragmentManager fragmentManager,%0A                                                     @NonNull final Fragment fragment,%0A                                                     @NonNull final String tag) %7B%0A        checkNotNull(fragmentManager, %22fragmentManager must not be null!%22);%0A        checkNotNull(fragment, %22fragment must not be null!%22);%0A        checkNotNull(tag, %22tag must not be null!%22);%0A        checkArgument(!tag.isEmpty(), %22tag string must not be empty!%22);%0A%0A        removeCurrentFragment(fragmentManager, tag);%0A%0A        final FragmentTransaction transaction = fragmentManager.beginTransaction();%0A        transaction.add(fragment, tag);%0A        transaction.commitAllowingStateLoss();%0A    %7D%0A%0A    /**%0A     * Retrieves the fragemnt with the given tag. If not exists then a new fragment will be created.%0A     *%0A     * @param fragmentManager The fragment manager used to find fragment.%0A     * @param tag Fragment tag.%0A     * @return The retrieved retained fragment or a its new instance.%0A     */%0A    @NonNull%0A    public static Fragment findOrCreateFragment(@NonNull final FragmentManager fragmentManager, @NonNull final String tag) %7B%0A        checkNotNull(fragmentManager, %22fragmentManager must not be null!%22);%0A        checkNotNull(tag, %22tag must not be null!%22);%0A        checkArgument(!tag.isEmpty(), %22tag string must not be empty!%22);%0A%0A        Fragment fragment = fragmentManager.findFragmentByTag(tag);%0A%0A        if (fragment == null) %7B%0A            fragment = DiffRequestManagerFragment.newInstance();%0A            addFragmentToActivity(fragmentManager, fragment, tag);%0A        %7D%0A%0A        return fragment;%0A    %7D%0A%0A    /**%0A     * Removes the current fragment with the same tag if it exists to prevent duplicates.%0A     * @param fragmentManager A fragment manager which manages the fragment removal.%0A     * @param tag A tag of the fragment that must be removed.%0A     */%0A    private static void removeCurrentFragment(@NonNull final FragmentManager fragmentManager,%0A                                              @NonNull final String tag) %7B%0A        final Fragment fragment = fragmentManager.findFragmentByTag(tag);%0A        if (fragment != null) %7B%0A            fragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss();%0A        %7D%0A    %7D%0A%7D%0A%0A

Add ActivityUtils helper methods