Java Code Examples for android.support.v4.app.FragmentManager

The following are top voted examples for showing how to use android.support.v4.app.FragmentManager. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: XinFramework   File: TransactionDelegate.java   View source code 7 votes vote down vote up
private void executeDebouncePop(FragmentManager fm) {
    Fragment popF = fm.findFragmentByTag(fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName());
    if (popF instanceof ISupportFragment) {
        ISupportFragment supportF = (ISupportFragment) popF;
        if (supportF.getSupportDelegate().mIsSharedElement) {
            long now = System.currentTimeMillis();
            if (now < mShareElementDebounceTime) {
                mShareElementDebounceTime = System.currentTimeMillis() + supportF.getSupportDelegate().mAnimHelper.exitAnim.getDuration();
                return;
            }
        }
        mShareElementDebounceTime = System.currentTimeMillis() + supportF.getSupportDelegate().mAnimHelper.exitAnim.getDuration();
    }

    fm.popBackStack();
}
 
Example 2
Project: ShotsNewsApp   File: HomeActivity.java   View source code 6 votes vote down vote up
void btnclick(View view)
{
    //Fragment fragment=null;
    switch (view.getId()){
        case R.id.btn_learn:
            fragment=new On_going_Courses_Fragment();
            break;
        case R.id.btn_explore:
      //      getNews();
            fragment=new NewsFragment();
            break;
        case R.id.btn_profile:
            fragment=new profile_fragment();
            break;

    }
    FragmentManager fragmentManager=getSupportFragmentManager();
    FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
    fragmentTransaction.replace(R.id.homeFrame_PlaceHolder,fragment);

    fragmentTransaction.commit();

}
 
Example 3
Project: Programmers   File: IntentUtils.java   View source code 6 votes vote down vote up
public static void showProgressFragmentDialog(Activity activity, boolean show) {
    try {
        FragmentManager fm = ((AppCompatActivity) activity).getSupportFragmentManager();

        if (show && progressFragmentDialog == null) {
            progressFragmentDialog = new ProgressFragmentDialog();
            progressFragmentDialog.show(fm, null);
            return;
        }

        if (show) {
            progressFragmentDialog.show(fm, null);
            return;
        }


        if (progressFragmentDialog == null) {
            return;
        }
        progressFragmentDialog.dismiss();
    }catch (Exception ex){
        ex.printStackTrace();
    }
}
 
Example 4
Project: open-rmbt   File: RMBTMainActivity.java   View source code 6 votes vote down vote up
public void showResultsAfterTest(String testUuid) {
	popBackStackFull();
	
    final RMBTResultPagerFragment fragment = new RMBTResultPagerFragment();
    final Bundle args = new Bundle();
    args.putString(RMBTResultPagerFragment.ARG_TEST_UUID, testUuid);
    fragment.setArguments(args);
    
    
    final FragmentManager fm = getSupportFragmentManager();
    final FragmentTransaction ft;
    ft = fm.beginTransaction();
    ft.replace(R.id.fragment_content, fragment, AppConstants.PAGE_TITLE_HISTORY_PAGER);
    ft.addToBackStack(AppConstants.PAGE_TITLE_HISTORY_PAGER);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    ft.commit();
    
    refreshActionBar(AppConstants.PAGE_TITLE_HISTORY_PAGER);
}
 
Example 5
Project: TripleTap   File: MainMenuFragment.java   View source code 6 votes vote down vote up
/**
 * Swaps in the Single Player Options Fragment
 */
@Override
public void openSinglePlayerOptions() {
    // Swap in single player menu fragment
    Fragment fragment = MainMenuSinglePlayerFragment.newInstance();

    // Set transitions
    fragment.setEnterTransition(mNewEnterTransition);
    fragment.setExitTransition(mNewExitTransition);

    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(R.id.menu_frame, fragment);
    transaction.addToBackStack(null);
    transaction.commit();
}
 
Example 6
Project: Chidori   File: ErrorDialogManager.java   View source code 6 votes vote down vote up
public void onEventMainThread(ThrowableFailureEvent event) {
    if (!isInExecutionScope(executionScope, event)) {
        return;
    }
    checkLogException(event);
    // Execute pending commits before finding to avoid multiple error fragments being shown
    FragmentManager fm = getFragmentManager();
    fm.executePendingTransactions();

    DialogFragment existingFragment = (DialogFragment) fm.findFragmentByTag(TAG_ERROR_DIALOG);
    if (existingFragment != null) {
        // Just show the latest error
        existingFragment.dismiss();
    }

    DialogFragment errorFragment = (DialogFragment) factory
            .prepareErrorFragment(event, finishAfterDialog, argumentsForErrorDialog);
    if (errorFragment != null) {
        errorFragment.show(fm, TAG_ERROR_DIALOG);
    }
}
 
Example 7
Project: MVVMArms   File: FragmentUtils.java   View source code 6 votes vote down vote up
/**
 * 新增多个fragment
 *
 * @param fragmentManager fragment管理器
 * @param fragments       fragments
 * @param containerId     布局Id
 * @param showIndex       要显示的fragment索引
 * @param lists           共享元素链表
 * @return 要显示的fragment
 */
public static Fragment addFragments(@NonNull FragmentManager fragmentManager,
                                    @NonNull List<Fragment> fragments,
                                    @IdRes int containerId,
                                    int showIndex,
                                    @NonNull List<SharedElement>... lists) {
    for (int i = 0, size = fragments.size(); i < size; ++i) {
        Fragment fragment = fragments.get(i);
        List<SharedElement> list = lists[i];
        if (fragment != null) {
            if (list != null) {
                putArgs(fragment, new Args(containerId, showIndex != i, false));
                return operateFragment(fragmentManager, null, fragment, TYPE_ADD_FRAGMENT, list.toArray(new SharedElement[0]));
            }
        }
    }
    return fragments.get(showIndex);
}
 
Example 8
Project: mvvm-template   File: AppInjector.java   View source code 6 votes vote down vote up
private static void handleActivity(Activity activity) {
    if (activity instanceof HasSupportFragmentInjector || activity instanceof Injectable) {
        AndroidInjection.inject(activity);
    }
    if (activity instanceof FragmentActivity) {
        ((FragmentActivity) activity).getSupportFragmentManager()
                .registerFragmentLifecycleCallbacks(
                        new FragmentManager.FragmentLifecycleCallbacks() {
                            @Override
                            public void onFragmentCreated(FragmentManager fm, Fragment f,
                                                          Bundle savedInstanceState) {
                                if (f instanceof Injectable) {
                                    AndroidSupportInjection.inject(f);
                                }
                            }
                        }, true);
    }
}
 
Example 9
Project: RxSocialAuth   File: RxFacebookAuth.java   View source code 6 votes vote down vote up
/**
 * Get instance of RxFacebookAuthFragment
 *
 * @return a RxFacebookAuthFragment
 */
private RxFacebookAuthFragment getRxFacebookAuthFragment(Builder builder) {
    FragmentManager fragmentManager = mActivity.getSupportFragmentManager();

    // prevent fragment manager already executing transaction
    int stackCount = fragmentManager.getBackStackEntryCount();
    if( fragmentManager.getFragments() != null )
        fragmentManager = fragmentManager.getFragments().get( stackCount > 0 ? stackCount-1 : stackCount ).getChildFragmentManager();

    RxFacebookAuthFragment rxFacebookAuthFragment = (RxFacebookAuthFragment)
            fragmentManager.findFragmentByTag(RxFacebookAuthFragment.TAG);

    if (rxFacebookAuthFragment == null) {
        rxFacebookAuthFragment = RxFacebookAuthFragment.newInstance(builder);
        fragmentManager
                .beginTransaction()
                .add(rxFacebookAuthFragment, RxFacebookAuthFragment.TAG)
                .commit();
        fragmentManager.executePendingTransactions();
    }
    return rxFacebookAuthFragment;
}
 
Example 10
Project: freehkkai-android   File: SettingsActivity.java   View source code 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	C.detectLanguage(mContext);

	setContentView(R.layout.activity_container_adview);
	ButterKnife.bind(this);
	setSupportActionBar(toolbar);

	initActionBar(getSupportActionBar(), R.string.title_activity_settings);

	Fragment fragment = SettingsFragment.newInstance();
	FragmentManager fragmentManager = getSupportFragmentManager();
	fragmentManager.beginTransaction()
			.replace(R.id.container, fragment)
			.commit();
}
 
Example 11
Project: chromium-for-android-56-debug-video   File: BaseMediaRouteDialogManager.java   View source code 6 votes vote down vote up
@Override
public void openDialog() {
    if (mAndroidMediaRouter == null) {
        mDelegate.onDialogCancelled();
        return;
    }

    FragmentActivity currentActivity =
            (FragmentActivity) ApplicationStatus.getLastTrackedFocusedActivity();
    if (currentActivity == null)  {
        mDelegate.onDialogCancelled();
        return;
    }

    FragmentManager fm = currentActivity.getSupportFragmentManager();
    if (fm == null)  {
        mDelegate.onDialogCancelled();
        return;
    }

    mDialogFragment = openDialogInternal(fm);
    if (mDialogFragment == null)  {
        mDelegate.onDialogCancelled();
        return;
    }
}
 
Example 12
Project: OldNews   File: MainPageAdapter.java   View source code 5 votes vote down vote up
public MainPageAdapter(FragmentManager fragmentManager, Context context){
    super(fragmentManager);
    mFragmentArrayList = new ArrayList<Fragment>();

    mFragmentArrayList.add(new FeedFragment());
    mFragmentArrayList.add(new FavouriteFeedFragment());
    //mFragmentArrayList.add(new FeedFragment());

    mTitleList = new ArrayList<String>();
    mTitleList.add(context.getResources().getString(R.string.feed_tab));
    mTitleList.add(context.getResources().getString(R.string.favorites_tab));
    //mTitleList.add(context.getResources().getString(R.string.ocr_tab));

}
 
Example 13
Project: TextEmoji   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 *
 */
public static void addFragmentToActivity (@NonNull FragmentManager fragmentManager,
                                          @NonNull Fragment fragment, int frameId) {
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(frameId, fragment);
    transaction.commit();
}
 
Example 14
Project: text_converter   File: ApplicationHelper.java   View source code 5 votes vote down vote up
@Nullable
public static ApplicationPagerAdapter setup(AutoScrollViewPager viewPager, FragmentManager fragmentManager, Context context) {
    if (viewPager == null) return null;
    DLog.d(TAG, "setup() called");
    ApplicationPagerAdapter adapter = new ApplicationPagerAdapter(fragmentManager, context);
    viewPager.setAdapter(adapter);
    viewPager.startAutoScroll();
    return adapter;
}
 
Example 15
Project: decoy   File: UI.java   View source code 5 votes vote down vote up
public List<TFragment> addFragments(List<TFragment> fragments) {
    List<TFragment> fragments2 = new ArrayList<TFragment>(fragments.size());

    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction transaction = fm.beginTransaction();

    boolean commit = false;
    for (int i = 0; i < fragments.size(); i++) {
        // install
        TFragment fragment = fragments.get(i);
        int id = fragment.getContainerId();

        // exists
        TFragment fragment2 = (TFragment) fm.findFragmentById(id);

        if (fragment2 == null) {
            fragment2 = fragment;
            transaction.add(id, fragment);
            commit = true;
        }

        fragments2.add(i, fragment2);
    }

    if (commit) {
        try {
            transaction.commitAllowingStateLoss();
        } catch (Exception e) {

        }
    }

    return fragments2;
}
 
Example 16
Project: hands-on-api-proxy   File: SingleFragmentActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getLayoutResId());

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);

    if (fragment == null) {
        fragment = createFragment();
        fm.beginTransaction()
                .add(R.id.fragment_container, fragment)
                .commit();
    }
}
 
Example 17
Project: mapbook-android   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 *
 */
public static void addFragmentToActivity (final FragmentManager fragmentManager,
    final Fragment fragment, final int frameId) {
  checkNotNull(fragmentManager);
  checkNotNull(fragment);
  final FragmentTransaction transaction = fragmentManager.beginTransaction();
  transaction.add(frameId, fragment);
  transaction.commit();
}
 
Example 18
Project: android-mvvm-architecture   File: BaseDialog.java   View source code 5 votes vote down vote up
public void show(FragmentManager fragmentManager, String tag) {
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    Fragment prevFragment = fragmentManager.findFragmentByTag(tag);
    if (prevFragment != null) {
        transaction.remove(prevFragment);
    }
    transaction.addToBackStack(null);
    show(transaction, tag);
}
 
Example 19
Project: GxIconDIY   File: RetainedFragment.java   View source code 5 votes vote down vote up
@NonNull
public static RetainedFragment initRetainedFragment(@NonNull FragmentManager fragmentManager,
                                                    @NonNull String tag) {
    RetainedFragment fragment = (RetainedFragment) fragmentManager.findFragmentByTag(tag);
    if (fragment == null) {
        fragment = new RetainedFragment();
        fragmentManager.beginTransaction().add(fragment, tag).commit();
    }
    return fragment;
}
 
Example 20
Project: RunMap   File: FragmentAdapter.java   View source code 5 votes vote down vote up
public FragmentAdapter(FragmentManager fm) {
    super(fm);
    mFragments = new ArrayList<>();
    mFragments.add(FunctionFragment.newInstance());
    mFragments.add(PersonalFragment.newInstance());
    mFragments.add(V2MainFragment.newInstance());
}
 
Example 21
Project: phonk   File: BaseActivity.java   View source code 5 votes vote down vote up
public void changeFragment(int id, Fragment fragment) {
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    fragmentTransaction.replace(id, fragment);
    fragmentTransaction.commit();
}
 
Example 22
Project: StopApp   File: ComponentPagerAdapter.java   View source code 5 votes vote down vote up
public ComponentPagerAdapter(FragmentManager fm, Context context) {
    super(fm);
    mFragments = new ArrayList<>();
    tabNames = new ArrayList<>();
    tabNames.add(context.getString(R.string.component_activity));
    tabNames.add(context.getString(R.string.component_service));
    tabNames.add(context.getString(R.string.component_receiver));
    tabNames.add(context.getString(R.string.component_provider));
}
 
Example 23
Project: MVPArms_Fragment-fragment   File: FragmentUtils.java   View source code 5 votes vote down vote up
/**
 * 移除所有fragment
 */
public static void removeAllFragments(@NonNull FragmentManager fragmentManager) {
    List<Fragment> fragments = getFragments(fragmentManager);
    if (fragments.isEmpty())
        return;
    for (int i = fragments.size() - 1; i >= 0; --i) {
        Fragment fragment = fragments.get(i);
        if (fragment != null) {
            removeAllFragments(fragment.getChildFragmentManager());
            removeFragment(fragment);
        }
    }
}
 
Example 24
Project: GmArchMvvm   File: FragmentUtils.java   View source code 5 votes vote down vote up
/**
 * Add multiple fragments
 *
 * @param fragmentManager fragment manager
 * @param fragments       fragments
 * @param containerId     Layout Id
 * @param showIndex       The fragment index to be displayed
 * @return The fragment to be displayed
 */
public static Fragment addFragments(@NonNull FragmentManager fragmentManager,
                                    @NonNull List<Fragment> fragments,
                                    @IdRes int containerId,
                                    int showIndex) {
    for (int i = 0, size = fragments.size(); i < size; ++i) {
        Fragment fragment = fragments.get(i);
        if (fragment != null) {
            addFragment(fragmentManager, fragment, containerId, showIndex != i, false);
        }
    }
    return fragments.get(showIndex);
}
 
Example 25
Project: MVVMArms   File: FragmentLifecycle.java   View source code 5 votes vote down vote up
@Override
public void onFragmentStopped(FragmentManager fm, Fragment f) {
    super.onFragmentStopped(fm, f);
    FragmentDelegate fragmentDelegate = fetchFragmentDelegate(f);
    if (fragmentDelegate != null) {
        Timber.i("%s ---> onFragmentStopped", f.toString());
        fragmentDelegate.onStop();
    }
}
 
Example 26
Project: aarLibrary   File: VisibleDelegate.java   View source code 5 votes vote down vote up
private void dispatchSupportVisible(boolean visible) {
    mIsSupportVisible = visible;

    if (!mNeedDispatch) {
        mNeedDispatch = true;
    } else {
        FragmentManager fragmentManager = mSupportFragment.getChildFragmentManager();
        if (fragmentManager != null) {
            List<Fragment> childFragments = fragmentManager.getFragments();
            if (childFragments != null) {
                for (Fragment child : childFragments) {
                    if (child instanceof SupportFragment && !child.isHidden() && child.getUserVisibleHint()) {
                        ((SupportFragment) child).getVisibleDelegate().dispatchSupportVisible(visible);
                    }
                }
            }
        }
    }

    if (visible) {
        mSupportFragment.onSupportVisible();

        if (mIsFirstVisible) {
            mIsFirstVisible = false;
            mSupportFragment.onLazyInitView(mSaveInstanceState);
        }
    } else {
        mSupportFragment.onSupportInvisible();
    }
}
 
Example 27
Project: AndroidProgramming3e   File: SingleFragmentActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fragment);

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);

    if (fragment == null) {
        fragment = createFragment();
        fm.beginTransaction()
                .add(R.id.fragment_container, fragment)
                .commit();
    }
}
 
Example 28
Project: Bigbang   File: BaseActivity.java   View source code 5 votes vote down vote up
public void switchFragment(Fragment fragment){
    if (currentFragment!=null&&currentFragment==fragment){
        return;
    }
    FragmentManager fm=getSupportFragmentManager();
    FragmentTransaction ft=fm.beginTransaction();
    if (currentFragment!=null){
        ft.hide(currentFragment);
    }
    ft.show(fragment);
    ft.commitAllowingStateLoss();
    currentFragment=fragment;
}
 
Example 29
Project: GmArchMvvm   File: FragmentUtils.java   View source code 5 votes vote down vote up
/**
 * Hide the same level fragment
 *
 * @param fragmentManager fragment manager
 */
public static void hideFragments(@NonNull FragmentManager fragmentManager) {
    List<Fragment> fragments = getFragments(fragmentManager);
    if (fragments.isEmpty())
        return;
    for (int i = fragments.size() - 1; i >= 0; --i) {
        Fragment fragment = fragments.get(i);
        if (fragment != null)
            hideFragment(fragment);
    }
}
 
Example 30
Project: firefox-tv   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public void onClick(View view) {
    final FragmentManager fragmentManager = getSupportFragmentManager();
    final BrowserFragment fragment = (BrowserFragment) fragmentManager.findFragmentByTag(BrowserFragment.FRAGMENT_TAG);
    if (fragment == null || !fragment.isVisible()) {
        return;
    }
    switch (view.getId()) {
        case R.id.drawer_refresh_button:
            fragment.reload();
            break;
        case R.id.drawer_back_button:
            if (fragment.canGoBack()) {
                fragment.goBack();
            }
            break;
        case R.id.drawer_forward_button:
            if (fragment.canGoForward()) {
                fragment.goForward();
            }
            break;
        default:
            // Return so that we don't try to close the drawer
            return;
    }
    drawer.closeDrawer(GravityCompat.START);
}
 
Example 31
Project: XinFramework   File: TransactionDelegate.java   View source code 5 votes vote down vote up
private void startWithPop(final FragmentManager fragmentManager, final ISupportFragment from, final ISupportFragment to) {
    if (FragmentationHack.isExecutingActions(fragmentManager)) {
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                executeStartWithPop(fragmentManager, from, to);
            }
        });
        return;
    }

    executeStartWithPop(fragmentManager, from, to);
}
 
Example 32
Project: NUI_Project   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 *
 */
public static void addFragmentToActivity (@NonNull FragmentManager fragmentManager,
                                          @NonNull Fragment fragment, int frameId) {
    checkNotNull(fragmentManager);
    checkNotNull(fragment);
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(frameId, fragment);
    transaction.commit();
}
 
Example 33
Project: GitHub   File: BaseDialog.java   View source code 5 votes vote down vote up
public void show(FragmentManager fragmentManager, String tag) {
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    Fragment prevFragment = fragmentManager.findFragmentByTag(tag);
    if (prevFragment != null) {
        transaction.remove(prevFragment);
    }
    transaction.addToBackStack(null);
    show(transaction, tag);
}
 
Example 34
Project: IslamicLibraryAndroid   File: BookmarkFragment.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_sort:
            SortListDialogFragment sortListDialogFragment = SortListDialogFragment.newInstance(
                    R.array.bookmark_list_sorting,
                    bookmarkRecyclerViewAdapter != null ? bookmarkRecyclerViewAdapter.getmCurrentSortIndex() : 0);
            //see this answer http://stackoverflow.com/a/37794319/3061221
            FragmentManager fm = getChildFragmentManager();
            sortListDialogFragment.show(fm, "fragment_sort");
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 35
Project: frogment   File: StateAwareFrogmentCallbacks.java   View source code 5 votes vote down vote up
@Override
public void onFragmentActivityCreated(FragmentManager fm, Fragment f, Bundle savedInstanceState) {
    super.onFragmentActivityCreated(fm, f, savedInstanceState);

    if (f instanceof StateAwareFrogment) {
        final StateAwareFrogment stateAwareFrogment = (StateAwareFrogment) f;

        stateAwareFrogment.onViewReady();
    }
}
 
Example 36
Project: ActivityStack   File: LifecycleUtils.java   View source code 5 votes vote down vote up
private void unregisterFragmentLifecycleCallback(Activity activity
        , FragmentManager.FragmentLifecycleCallbacks callbacks) {
    if (callbacks != null && activity instanceof FragmentActivity) {
        FragmentManager supportFragmentManager = ((FragmentActivity) activity).getSupportFragmentManager();
        supportFragmentManager.unregisterFragmentLifecycleCallbacks(callbacks);
    }
}
 
Example 37
Project: AndroidProgramming3e   File: CrimeActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_crime);

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);

    if (fragment == null) {
        fragment = new CrimeFragment();
        fm.beginTransaction()
            .add(R.id.fragment_container, fragment)
            .commit();
    }
}
 
Example 38
Project: easyfilemanager   File: DetailFragment.java   View source code 5 votes vote down vote up
public static void showAsDialog(FragmentManager fm, DocumentInfo doc) {
final Bundle args = new Bundle();
args.putParcelable(EXTRA_DOC, doc);
args.putBoolean(EXTRA_IS_DIALOG, true);

final DetailFragment fragment = new DetailFragment();
fragment.setArguments(args);
fragment.show(fm, TAG_DETAIL);
  }
 
Example 39
Project: AndroidProgramming3e   File: SingleFragmentActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getLayoutResId());

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);

    if (fragment == null) {
        fragment = createFragment();
        fm.beginTransaction()
                .add(R.id.fragment_container, fragment)
                .commit();
    }
}
 
Example 40
Project: MVPArms_Fragment-fragment   File: ActivityLifecycle.java   View source code 5 votes vote down vote up
@Override
public void onFragmentStopped(FragmentManager fm, Fragment f) {
    super.onFragmentStopped(fm, f);
    Timber.w(f.toString() + " - onFragmentStopped");
    FragmentDelegate fragmentDelegate = fetchFragmentDelegate(f);
    if (fragmentDelegate != null) {
        fragmentDelegate.onStop();
    }
}