当前位置: 首页>>代码示例>>Java>>正文


Java FragmentTransaction.commitAllowingStateLoss方法代码示例

本文整理汇总了Java中android.app.FragmentTransaction.commitAllowingStateLoss方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentTransaction.commitAllowingStateLoss方法的具体用法?Java FragmentTransaction.commitAllowingStateLoss怎么用?Java FragmentTransaction.commitAllowingStateLoss使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.FragmentTransaction的用法示例。


在下文中一共展示了FragmentTransaction.commitAllowingStateLoss方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showDialogFragment

import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void showDialogFragment(int dialogId, String customMessage) {
    if (mDestroyed) {
        return;
    }
    mProgressBar.setIndeterminate(false);

    DialogFragment fragment;
    switch (dialogId) {
        case R.id.dialog_account_setup_error: {
            fragment = ConfirmationDialogFragment.newInstance(dialogId,
                    getString(R.string.account_setup_failed_dlg_title),
                    customMessage,
                    getString(R.string.account_setup_failed_dlg_edit_details_action),
                    getString(R.string.account_setup_failed_dlg_continue_action)
            );
            break;
        }
        default: {
            throw new RuntimeException("Called showDialog(int) with unknown dialog id.");
        }
    }

    FragmentTransaction ta = getFragmentManager().beginTransaction();
    ta.add(fragment, getDialogTag(dialogId));
    ta.commitAllowingStateLoss();

    // TODO: commitAllowingStateLoss() is used to prevent https://code.google.com/p/android/issues/detail?id=23761
    // but is a bad...
    //fragment.show(ta, getDialogTag(dialogId));
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:31,代码来源:AccountSetupCheckSettings.java

示例2: removeFragment

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void removeFragment(FragmentManager fragmentManager, int containViewId)
{
	if(fragmentManager != null) {
		Fragment fragment = fragmentManager.findFragmentById(containViewId);
		if (fragment != null)
		{
			fragments.remove(fragment);
			
			// TODO: Remove from backStackKeys
			
			FragmentTransaction transaction = fragmentManager.beginTransaction();
			transaction.remove(fragment);
			transaction.commitAllowingStateLoss();
		}
	}
	else {
		Log.e("FragmentHelper", "Fragment Manager = null");
	}
}
 
开发者ID:WowWeeLabs,项目名称:CHIP-Android-SDK,代码行数:20,代码来源:FragmentHelper.java

示例3: clearAllBackStackFragments

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void clearAllBackStackFragments(FragmentManager fragmentManager)
{
	FragmentTransaction ft = fragmentManager.beginTransaction();

    for (WeakReference<Fragment> ref : fragments) {
        Fragment fragment = ref.get();
        if (fragment != null) {
            ft.remove(fragment);
        }
    }
    fragments.clear();
    backStackKeys.clear();

    ft.commitAllowingStateLoss();
}
 
开发者ID:WowWeeLabs,项目名称:CHIP-Android-SDK,代码行数:16,代码来源:FragmentHelper.java

示例4: reloadFragment

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void reloadFragment(FragmentManager fragmentManager, Fragment fragment) {
		if (fragment != null){
			FragmentTransaction ft = fragmentManager.beginTransaction();
//			ft.setTransition(-1);
	//		ft.replace(containViewId, fragment);
			ft.detach(fragment);
			ft.attach(fragment);
			ft.commitAllowingStateLoss();
		}
	}
 
开发者ID:WowWeeLabs,项目名称:CHIP-Android-SDK,代码行数:11,代码来源:FragmentHelper.java

示例5: show

import android.app.FragmentTransaction; //导入方法依赖的package包/类
private static void show(FragmentManager fm, int type, RootInfo root, DocumentInfo doc, String query, int anim) {
	final Bundle args = new Bundle();
	args.putInt(EXTRA_TYPE, type);
	args.putParcelable(EXTRA_ROOT, root);
	args.putParcelable(EXTRA_DOC, doc);
	args.putString(EXTRA_QUERY, query);

	final FragmentTransaction ft = fm.beginTransaction();
	switch (anim) {
	case ANIM_SIDE:
		args.putBoolean(EXTRA_IGNORE_STATE, true);
		break;
	case ANIM_DOWN:
		ft.setCustomAnimations(R.animator.dir_down, R.animator.dir_frozen);
		break;
	case ANIM_UP:
		ft.setCustomAnimations(R.animator.dir_frozen, R.animator.dir_up);
		break;
	}

	final DirectoryFragment fragment = new DirectoryFragment();
	fragment.setArguments(args);

	ft.replace(R.id.container_directory, fragment);
	ft.commitAllowingStateLoss();
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:27,代码来源:DirectoryFragment.java

示例6: removeFragment

import android.app.FragmentTransaction; //导入方法依赖的package包/类
@SuppressWarnings("SameParameterValue")
private void removeFragment(final Fragment fragment, final boolean addToBackStack,
                            final boolean allowStateLoss) {
    final FragmentManager fm = getFragmentManager();

    final FragmentTransaction transaction = fm.beginTransaction();

    final String tag;

    if (fragment instanceof CurrentFeedFragment) {
        tag = CurrentFeedFragment.TAG;
    } else if (fragment instanceof FeedSubscriptionsFragment) {
        tag = FeedSubscriptionsFragment.TAG;
    } else if (fragment instanceof SavedEntriesFragment) {
        tag = SavedEntriesFragment.TAG;
    } else if (fragment instanceof InitialSetupFragment) {
        tag = InitialSetupFragment.TAG;
    } else {
        tag = LoadCurrentFeedFragment.TAG;
    }

    transaction.remove(fragment);

    if (addToBackStack) {
        transaction.addToBackStack(tag);
    }

    if (allowStateLoss) {
        transaction.commitAllowingStateLoss();
    } else {
        transaction.commit();
    }
    fm.executePendingTransactions();
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:35,代码来源:MainActivity.java

示例7: replaceHasHistory

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public void replaceHasHistory(int containerId, Fragment fragment) {
    if (currentFragment==fragment) {
        return;
    }
    FragmentTransaction ft = fm.beginTransaction();
    ft.replace(containerId, fragment);
    ft.addToBackStack(null);//添加这个会在按返回键的时候先退出fragment,一些特殊场合可能用到,但效果其实不理想
    ft.commitAllowingStateLoss();
    currentFragment = fragment;
}
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:11,代码来源:FragmentUtil.java

示例8: removeAll

import android.app.FragmentTransaction; //导入方法依赖的package包/类
/**清空所有fragment*/
public void removeAll(){
    FragmentTransaction ft = fm.beginTransaction();
    for (Fragment f:fs) {
        ft.remove(f);
    }
    ft.commitAllowingStateLoss();
}
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:9,代码来源:FragmentUtil.java

示例9: show

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void show(FragmentManager fm) {
    final ConnectionsFragment fragment = new ConnectionsFragment();
    final FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.container_directory, fragment, TAG);
    ft.commitAllowingStateLoss();
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:7,代码来源:ConnectionsFragment.java

示例10: changeFragmentForTablets

import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void changeFragmentForTablets(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
	if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
		if (newFragmentType == FragmentsAvailable.DIALER) {
			showStatusBar();
		} else {
			hideStatusBar();
		}
	}
	emptyFragment = false;
	LinearLayout ll = (LinearLayout) findViewById(R.id.fragmentContainer2);

	FragmentTransaction transaction = getFragmentManager().beginTransaction();

	if(newFragmentType == FragmentsAvailable.EMPTY){
		ll.setVisibility(View.VISIBLE);
		emptyFragment = true;
		transaction.replace(R.id.fragmentContainer2, newFragment);
		transaction.commitAllowingStateLoss();
		getFragmentManager().executePendingTransactions();
	} else {
		if (newFragmentType.shouldAddItselfToTheRightOf(currentFragment)) {
			ll.setVisibility(View.VISIBLE);

			if (newFragmentType == FragmentsAvailable.CONTACT_EDITOR) {
				transaction.addToBackStack(newFragmentType.toString());
			}
			transaction.replace(R.id.fragmentContainer2, newFragment);
		} else {
			if (newFragmentType == FragmentsAvailable.EMPTY) {
				ll.setVisibility(View.VISIBLE);
				transaction.replace(R.id.fragmentContainer2, new EmptyFragment());
				emptyFragment = true;
			}

			if (newFragmentType == FragmentsAvailable.DIALER
					|| newFragmentType == FragmentsAvailable.ABOUT
					|| newFragmentType == FragmentsAvailable.SETTINGS
					|| newFragmentType == FragmentsAvailable.ACCOUNT_SETTINGS) {
				ll.setVisibility(View.GONE);
			} else {
				ll.setVisibility(View.VISIBLE);
				transaction.replace(R.id.fragmentContainer2, new EmptyFragment());
			}

			/*if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
				if (newFragmentType.isRightOf(currentFragment)) {
					transaction.setCustomAnimations(R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left, R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right);
				} else {
					transaction.setCustomAnimations(R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right, R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left);
				}
			}*/
			transaction.replace(R.id.fragmentContainer, newFragment);
		}
		transaction.commitAllowingStateLoss();
		getFragmentManager().executePendingTransactions();

		currentFragment = newFragmentType;
		if (newFragmentType == FragmentsAvailable.DIALER
				|| newFragmentType == FragmentsAvailable.SETTINGS
				|| newFragmentType == FragmentsAvailable.CONTACTS_LIST
				|| newFragmentType == FragmentsAvailable.CHAT_LIST
				|| newFragmentType == FragmentsAvailable.HISTORY_LIST) {
			try {
				getFragmentManager().popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
			} catch (IllegalStateException e) {

			}
		}
		fragmentsHistory.add(currentFragment);
	}
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:72,代码来源:LinphoneActivity.java

示例11: replaceFragmentVideoByAudio

import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void replaceFragmentVideoByAudio() {
	audioCallFragment = new CallAudioFragment();
	FragmentTransaction transaction = getFragmentManager().beginTransaction();
	transaction.replace(R.id.fragmentContainer, audioCallFragment);
	try {
		transaction.commitAllowingStateLoss();
	} catch (Exception e) {
	}
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:10,代码来源:CallActivity.java

示例12: addFragmentToActivity

import android.app.FragmentTransaction; //导入方法依赖的package包/类
/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 *
 * @param fragmentManager {@link FragmentManager} associated with {@link android.app.Activity}.
 * @param fragment        {@link Fragment} to add.
 * @param tag             A string identifying the fragment.
 */
public static void addFragmentToActivity(@NonNull final FragmentManager fragmentManager,
                                         @NonNull final Fragment fragment,
                                         @NonNull final String tag) {
    checkNotNull(fragmentManager, "fragmentManager must not be null!");
    checkNotNull(fragment, "fragment must not be null!");
    checkNotNull(tag, "tag must not be null!");
    checkArgument(!tag.isEmpty(), "tag string must not be empty!");

    removeFragment(fragmentManager, tag);

    final FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(fragment, tag);
    transaction.commitAllowingStateLoss();
}
 
开发者ID:storix,项目名称:RxDiffUtil,代码行数:23,代码来源:ActivityUtils.java

示例13: show

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void show(FragmentManager fm) {
    final HomeFragment fragment = new HomeFragment();
    final FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.container_directory, fragment, TAG);
    ft.commitAllowingStateLoss();
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:7,代码来源:HomeFragment.java

示例14: show

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void show(FragmentManager fm, ArrayList<DocumentInfo> docs, boolean deleteAfter) {
	final Bundle args = new Bundle();
	args.putParcelableArrayList(EXTRA_DOC_LIST, docs);
	args.putBoolean(EXTRA_DELETE_AFTER, deleteAfter);
	
	final MoveFragment fragment = new MoveFragment();
	fragment.setArguments(args);

	final FragmentTransaction ft = fm.beginTransaction();
	ft.replace(R.id.container_save, fragment, TAG);
	ft.commitAllowingStateLoss();
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:13,代码来源:MoveFragment.java

示例15: show

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void show(FragmentManager fm, Intent includeApps) {
    final Bundle args = new Bundle();
    args.putParcelable(EXTRA_INCLUDE_APPS, includeApps);

    final RootsFragment fragment = new RootsFragment();
    fragment.setArguments(args);

    final FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.container_roots, fragment);
    ft.commitAllowingStateLoss();
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:12,代码来源:RootsFragment.java


注:本文中的android.app.FragmentTransaction.commitAllowingStateLoss方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。