當前位置: 首頁>>代碼示例>>Java>>正文


Java FragmentTransaction.commitAllowingStateLoss方法代碼示例

本文整理匯總了Java中android.support.v4.app.FragmentTransaction.commitAllowingStateLoss方法的典型用法代碼示例。如果您正苦於以下問題:Java FragmentTransaction.commitAllowingStateLoss方法的具體用法?Java FragmentTransaction.commitAllowingStateLoss怎麽用?Java FragmentTransaction.commitAllowingStateLoss使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.app.FragmentTransaction的用法示例。


在下文中一共展示了FragmentTransaction.commitAllowingStateLoss方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: reloadData

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
/**
 * 重新加載數據
 *
 * @param newListFragments 新的fragment集合
 * @param newSelectedList  新的選中分類集合
 */
public void reloadData(List<? extends BaseFragment> newListFragments, List<ColumnBean> newSelectedList) {

    // 每次刷新順序都需要清除緩存
    if (mListFragments.size() > 0) {
        FragmentTransaction ft = mFm.beginTransaction();
        for (Fragment f :
                mListFragments) {
            ft.remove(f);
        }
        ft.commitAllowingStateLoss();
        mFm.executePendingTransactions();
    }

    // 清除原有數據源
    mListFragments.clear();
    mSelectedList.clear();

    // 重新添加數據源
    mListFragments.addAll(newListFragments);
    mSelectedList.addAll(newSelectedList);

    // 刷新數據
    notifyDataSetChanged();
}
 
開發者ID:6ag,項目名稱:LiuAGeAndroid,代碼行數:31,代碼來源:TabFragmentPagerAdapter.java

示例2: addFragments

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
public void addFragments(Fragment... fragments) {
    if (fragments != null && fragments.length != 0) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        for (Fragment fragment : fragments) {
            if (fragment instanceof LetvFragmentListener) {
                LetvFragmentListener listener = (LetvFragmentListener) fragment;
                String tag = listener.getTagName();
                if (!TextUtils.isEmpty(tag)) {
                    int fragmentRes = listener.getContainerId();
                    if (fragmentRes > 0 && fragmentManager.findFragmentByTag(tag) == null) {
                        transaction.add(fragmentRes, fragment, tag);
                    }
                }
            }
        }
        try {
            transaction.commitAllowingStateLoss();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:24,代碼來源:LetvBaseActivity.java

示例3: changeFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
public static void changeFragment(FragmentActivity activity, Fragment nextFragment, boolean addToBackStack) {
        String name = nextFragment.getClass().getSimpleName();

        final FragmentManager fragmentManager = activity.getSupportFragmentManager();

        final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.setCustomAnimations(R.anim.slide_left_in, R.anim.slide_right_in, R.anim.slide_left_out, R.anim.slide_right_out);

        fragmentTransaction.replace(R.id.frame_content, nextFragment);

        if (addToBackStack) {
            fragmentTransaction.addToBackStack(name);
        }
        try {
            fragmentTransaction.commitAllowingStateLoss();
            fragmentManager.executePendingTransactions();
        } catch (IllegalStateException e) {
        }

}
 
開發者ID:Ubudu,項目名稱:GoogleMapsLayout-Android,代碼行數:21,代碼來源:FragmentUtils.java

示例4: showAlreadyOpenDialog

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
@TargetApi(17)
private void showAlreadyOpenDialog() {
    FragmentManager fm = getSupportFragmentManager();
    if (fm != null && getActivity() != null && !getActivity().isDestroyed()) {
        FragmentTransaction ft = fm.beginTransaction();
        this.mAlipayAutoPayAlreadyOpenDialog = (AlipayAutoPayAlreadyOpenDialog) fm.findFragmentByTag("showmAlipayAutoPayAlreadyOpenDialog");
        if (this.mAlipayAutoPayAlreadyOpenDialog == null) {
            this.mAlipayAutoPayAlreadyOpenDialog = new AlipayAutoPayAlreadyOpenDialog();
        } else {
            ft.remove(this.mAlipayAutoPayAlreadyOpenDialog);
        }
        this.mAlipayAutoPayAlreadyOpenDialog.setAlipayConfirmCallback(this);
        ft.add(this.mAlipayAutoPayAlreadyOpenDialog, "showmAlipayAutoPayAlreadyOpenDialog");
        ft.commitAllowingStateLoss();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:17,代碼來源:VipOrderDetailActivity.java

示例5: finish

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
public void finish() {
    super.finish();
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    for (int key : sActualFragments.keySet()) {
        Fragment fragment = getSupportFragmentManager().findFragmentByTag(key + "_key");
        if (fragment != null) {
            fragmentTransaction.remove(fragment);
        }
    }
    fragmentTransaction.commitAllowingStateLoss();
    if (mAdsFetcher != null) {
        mAdsFetcher.cancel();
    }
    RootUtils.closeSU();
}
 
開發者ID:AyushR1,項目名稱:KernelAdiutor-Mod,代碼行數:17,代碼來源:NavigationActivity.java

示例6: onSwitchInputUrl

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
public void onSwitchInputUrl() {
    setCenterTitle("輸入地址");
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    hiddenOnLineFragment(ft);
    hiddenLocalVideoFragment(ft);
    hiddenLocalVideoPlayGoFragment(ft);
    hiddenOutlineFragment(ft);
    if(inputUrlFragment==null){
        inputUrlFragment = new InputUrlFragment();
        ft.add(getUserContentHolder().getContainer().getId(),inputUrlFragment);
    }else{
        ft.show(inputUrlFragment);
    }
    ft.commitAllowingStateLoss();
}
 
開發者ID:jiajunhui,項目名稱:PlayerBase,代碼行數:17,代碼來源:HomeActivity.java

示例7: showFilterDialog

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
public static void showFilterDialog(FragmentManager fm, boolean isMuzei) {
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag(TAG);
    if (prev != null) {
        ft.remove(prev);
    }

    ft.add(newInstance(isMuzei), TAG)
            .setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);

    try {
        ft.commit();
    } catch (IllegalStateException e) {
        ft.commitAllowingStateLoss();
    }
}
 
開發者ID:danimahardhika,項目名稱:wallpaperboard,代碼行數:17,代碼來源:FilterFragment.java

示例8: processRestoreInstanceState

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
private void processRestoreInstanceState(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        FragmentTransaction ft = mFragment.getFragmentManager().beginTransaction();
        if (mIsHidden) {
            ft.hide(mFragment);
        } else {
            ft.show(mFragment);
        }
        ft.commitAllowingStateLoss();
    }
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:12,代碼來源:SupportFragmentDelegate.java

示例9: replaceFragmentWithBackStack

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
/**
     * 替換fragement 並添加動畫
     * 替換fragement的同時對fragment進行“入back棧”操作 ,據我所知並不是真正的進入內存棧
     *
     * @param id_content
     * @param anim_in
     * @param anim_out
     * @param fragment
     */
    @Deprecated
    public void replaceFragmentWithBackStack(@IdRes int id_content, @AnimRes int anim_in, @AnimRes int anim_out, Fragment fragment) {
        String tag = fragment.getClass().getSimpleName();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
//        transaction.setCustomAnimations(anim_in, anim_out);
        transaction.replace(id_content, fragment, tag);
        //記錄commit一次操作,與mFragmentManager.popBackStack();匹配使用
        transaction.addToBackStack(tag);
        //commitAllowingStateLoss 優於 commit 方法,當使用commit方法時,係統將進行狀態判斷,如果狀態(mStateSaved)已經保存,將發生"Can not perform this action after onSaveInstanceState"錯誤。
        //如果mNoTransactionsBecause已經存在,將發生"Can not perform this action inside of " + mNoTransactionsBecause錯誤。
        transaction.commitAllowingStateLoss();
    }
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:22,代碼來源:BActivity.java

示例10: onCreate

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ad);
    String type = getIntent().getStringExtra("type");
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.fragment_container, BetListFragment.newInstance(1, type));
    transaction.commitAllowingStateLoss();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:9,代碼來源:BetAllActivity.java

示例11: show

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
public static void show(FragmentManager fm, DocumentInfo doc) {
	final Bundle args = new Bundle();
	args.putParcelable(EXTRA_DOC, doc);
	
	final DetailFragment fragment = new DetailFragment();
	fragment.setArguments(args);

	final FragmentTransaction ft = fm.beginTransaction();
	ft.replace(R.id.container_info, fragment, TAG_DETAIL);
	ft.commitAllowingStateLoss();
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:12,代碼來源:DetailFragment.java

示例12: removeDialogFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
protected void removeDialogFragment(){
    FragmentManager fm=getSupportFragmentManager();
    FragmentTransaction ft=fm.beginTransaction();
    List<Fragment> fragments=fm.getFragments();
    if (fragments==null){
        return;
    }
    for (Fragment fragment:fragments){
        if (fragment instanceof DialogFragment){
            ft.remove(fragment);
        }
    }
    ft.commitAllowingStateLoss();
}
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:15,代碼來源:BaseActivity.java

示例13: removeCurrentFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
private void removeCurrentFragment() {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

    Fragment currentFrag = getSupportFragmentManager()
            .findFragmentById(R.id.mainContainer);

    if (currentFrag != null) {
        transaction.remove(currentFrag);
    }
    transaction.commitAllowingStateLoss();
}
 
開發者ID:hdpavan,項目名稱:FragmentTransaction,代碼行數:12,代碼來源:MainActivity.java

示例14: replaceFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
public void replaceFragment(Fragment fragment, final boolean addToBackStack) {
    final String fragmentName = fragment.getClass().getName();
    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    if (addToBackStack) {
        ft.addToBackStack(fragmentName);
    }
    ft.replace(getFragmentTransactionReplacementResource(), fragment, fragmentName);
    if (!(this.isDestroyed() || isFinishing())) {
        ft.commitAllowingStateLoss();
    }
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:12,代碼來源:BaseFragmentActivity.java

示例15: addFragmentToActivity

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
/**
 * 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, String tag, int enterAnimation, int exitAnimation,
                                         int popEnter, int popExit) {

    checkNotNull(fragmentManager);
    checkNotNull(fragment);

    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.setCustomAnimations(enterAnimation, exitAnimation, popEnter, popExit);
    fragmentTransaction.replace(frameId, fragment, tag);
    fragmentTransaction.addToBackStack(null);
    fragmentTransaction.commitAllowingStateLoss();
}
 
開發者ID:sciage,項目名稱:FinalProject,代碼行數:19,代碼來源:ActivityUtils.java


注:本文中的android.support.v4.app.FragmentTransaction.commitAllowingStateLoss方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。