Java Code Examples for android.support.v4.app.Fragment#onPause()

The following examples show how to use android.support.v4.app.Fragment#onPause() . 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: TabManager.java    From ForPDA with GNU General Public License v3.0 5 votes vote down vote up
private void hideTabs(FragmentTransaction transaction) {
    for (Fragment fragment : existingFragments) {
        if (fragment != null && !fragment.isHidden()) {
            transaction.hide(fragment);
            fragment.onPause();
        }
    }
}
 
Example 2
Source File: ZhiHuAdapter.java    From CoordinatorLayoutExample with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkId) {
    for (int i = 0; i < radioGroup.getChildCount(); i++) {
        if (radioGroup.getChildAt(i).getId() == checkId) {
            //  即将要展示的Fragment
            Fragment target = mFragmentList.get(i);
            Fragment currentFragment = getCurrentFragment();
            currentFragment.onPause();

            FragmentTransaction fragmentTransaction = getFragmentTransaction();
            if (target.isAdded()) {
                target.onResume();
                fragmentTransaction.show(target).hide(currentFragment);

            } else {
                fragmentTransaction.add(mContentId, target).show(target).hide(currentFragment);
            }
            fragmentTransaction.commit();
            currentTab = i;

            if (mFragmentToogleListener != null) {
                mFragmentToogleListener.onToogleChange(target, currentTab);
            }

        }
    }

}
 
Example 3
Source File: MainActivity.java    From 4pdaClient-plus with Apache License 2.0 5 votes vote down vote up
public void hideFragments(FragmentTransaction transaction, boolean withAnimation) {
    if (getSupportFragmentManager().getFragments() == null) return;
    if (withAnimation)
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
    else
        transaction.setTransition(FragmentTransaction.TRANSIT_NONE);
    for (Fragment fr : getSupportFragmentManager().getFragments()) {
        if (fr != null) {
            if (fr.isVisible())
                fr.onPause();
            transaction.hide(fr);
        }
    }
}
 
Example 4
Source File: MainActivity.java    From 4pdaClient-plus with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPause() {
    super.onPause();
    activityPaused = true;
    if (!(String.valueOf(App.getInstance().getCurrentFragmentTag())).equals("null")) {
        Fragment fragment = getSupportFragmentManager().findFragmentByTag(App.getInstance().getCurrentFragmentTag());
        if (fragment != null) {
            fragment.onPause();
        }
    }
}