當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。