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


Java FragmentManager.executePendingTransactions方法代码示例

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


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

示例1: fragmentFor

import android.app.FragmentManager; //导入方法依赖的package包/类
public static MessengerFragment fragmentFor(Activity activity) {
  FragmentManager fm = activity.getFragmentManager();
  if (fm.isDestroyed()) {
    throw new IllegalStateException("Activity already destroyed");
  }
  Fragment fragmentByTag = fm.findFragmentByTag(FRAGMENT_TAG);
  if (fragmentByTag != null && !(fragmentByTag instanceof MessengerFragment)) {
    throw new IllegalStateException("Unexpected "
        + "fragment instance was returned by FRAGMENT_TAG");
  }
  MessengerFragment fragment = (MessengerFragment) fragmentByTag;
  if (fragment == null) {
    fragment = new MessengerFragment();
    fm.beginTransaction().add(fragment, FRAGMENT_TAG)
        .commitAllowingStateLoss();
    // 接下来需要立刻通过这个 Fragment 来启动 Activity,所以需要立刻添加到 Activity 中
    fm.executePendingTransactions();
  }
  return fragment;
}
 
开发者ID:douo,项目名称:ActivityBuilder,代码行数:21,代码来源:MessengerFragment.java

示例2: removeDialog

import android.app.FragmentManager; //导入方法依赖的package包/类
private void removeDialog(int dialogId) {
    FragmentManager fm = getFragmentManager();

    if (fm == null || isRemoving() || isDetached()) {
        return;
    }

    // Make sure the "show dialog" transaction has been processed when we call
    // findFragmentByTag() below. Otherwise the fragment won't be found and the dialog will
    // never be dismissed.
    fm.executePendingTransactions();

    DialogFragment fragment = (DialogFragment) fm.findFragmentByTag(getDialogTag(dialogId));

    if (fragment != null) {
        fragment.dismiss();
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:19,代码来源:MessageViewFragment.java

示例3: changeFragment

import android.app.FragmentManager; //导入方法依赖的package包/类
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
	FragmentManager fm = getFragmentManager();
	FragmentTransaction transaction = fm.beginTransaction();

	/*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);
		}
	}*/

	if (newFragmentType != FragmentsAvailable.DIALER
			&& newFragmentType != FragmentsAvailable.CONTACTS_LIST
			&& newFragmentType != FragmentsAvailable.CHAT_LIST
			&& newFragmentType != FragmentsAvailable.HISTORY_LIST) {
		transaction.addToBackStack(newFragmentType.toString());
	} else {
		while (fm.getBackStackEntryCount() > 0) {
			fm.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
		}
	}

	transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString());
	transaction.commitAllowingStateLoss();
	fm.executePendingTransactions();

	currentFragment = newFragmentType;
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:36,代码来源:LinphoneActivity.java

示例4: initializeFragmentAndCheck

import android.app.FragmentManager; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.M)
private void initializeFragmentAndCheck(@NonNull String[] allPermissions, @NonNull List<String> deniedPermissions, @NonNull List<String> grantedPermissions)
{
    MayiFragment frag = (MayiFragment) mActivity.get().getFragmentManager().findFragmentByTag(MayiFragment.TAG);
    if (frag == null)
    {
        final FragmentManager fragmentManager = mActivity.get().getFragmentManager();
        frag = new MayiFragment();
        frag.setRetainInstance(true);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
        {
            fragmentManager.beginTransaction().add(frag, MayiFragment.TAG).commit();
            fragmentManager.executePendingTransactions();
        }
        else
            fragmentManager.beginTransaction().add(frag, MayiFragment.TAG).commitNow();

    }
    frag.setListeners(mPermissionResultListener, mPermissionsResultMultiListener, mRationaleSingleListener, mRationaleMultiListener);
    frag.checkPermissions(allPermissions, deniedPermissions, grantedPermissions);
}
 
开发者ID:ThanosFisherman,项目名称:MayI,代码行数:22,代码来源:Mayi.java

示例5: removeFragment

import android.app.FragmentManager; //导入方法依赖的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

示例6: SimpleRuntimePermission

import android.app.FragmentManager; //导入方法依赖的package包/类
public SimpleRuntimePermission(Activity activity) {

        if (activity == null) {
            throw new IllegalArgumentException("activity can't be empty");
        }

        mActivity = activity;

        FragmentManager fragmentManager = mActivity.getFragmentManager();

        Fragment permissionFragment = fragmentManager.findFragmentByTag(TAG);
        if (permissionFragment == null) {
            permissionFragment = new PermissionFragment();

            fragmentManager.beginTransaction()
                    .add(permissionFragment, TAG)
                    .commitAllowingStateLoss();
            fragmentManager.executePendingTransactions();
        }

        mPermissionFragment = (PermissionFragment) permissionFragment;
    }
 
开发者ID:imfms,项目名称:simple-runtime-permission,代码行数:23,代码来源:SimpleRuntimePermission.java

示例7: getRxPermissionsFragment

import android.app.FragmentManager; //导入方法依赖的package包/类
private RxPermissionsFragment getRxPermissionsFragment(Activity activity) {
    RxPermissionsFragment rxPermissionsFragment = findRxPermissionsFragment(activity);
    boolean isNewInstance = rxPermissionsFragment == null;
    if (isNewInstance) {
        rxPermissionsFragment = new RxPermissionsFragment();
        FragmentManager fragmentManager = activity.getFragmentManager();
        fragmentManager
                .beginTransaction()
                .add(rxPermissionsFragment, TAG)
                .commitAllowingStateLoss();
        fragmentManager.executePendingTransactions();
    }
    return rxPermissionsFragment;
}
 
开发者ID:ChangWeiBa,项目名称:AesExoPlayer,代码行数:15,代码来源:RxPermissions.java

示例8: getRxActivityResultsFragment

import android.app.FragmentManager; //导入方法依赖的package包/类
private RxActivityResultsFragment getRxActivityResultsFragment(Activity activity) {
    RxActivityResultsFragment fragment = findRxActivityResultsFragment(activity);
    if (fragment == null) {
        fragment = new RxActivityResultsFragment();
        FragmentManager fragmentManager = activity.getFragmentManager();
        fragmentManager.beginTransaction()
                .add(fragment, TAG)
                .commitAllowingStateLoss();
        fragmentManager.executePendingTransactions();
    }
    return fragment;
}
 
开发者ID:mohamad-amin,项目名称:RxActivityResults,代码行数:13,代码来源:RxActivityResults.java

示例9: onEventMainThread

import android.app.FragmentManager; //导入方法依赖的package包/类
public void onEventMainThread(ThrowableFailureEvent event) {
    if (ErrorDialogManager.isInExecutionScope(this.executionScope, event)) {
        ErrorDialogManager.checkLogException(event);
        FragmentManager fm = getFragmentManager();
        fm.executePendingTransactions();
        DialogFragment existingFragment = (DialogFragment) fm.findFragmentByTag(ErrorDialogManager.TAG_ERROR_DIALOG);
        if (existingFragment != null) {
            existingFragment.dismiss();
        }
        DialogFragment errorFragment = (DialogFragment) ErrorDialogManager.factory.prepareErrorFragment(event, this.finishAfterDialog, this.argumentsForErrorDialog);
        if (errorFragment != null) {
            errorFragment.show(fm, ErrorDialogManager.TAG_ERROR_DIALOG);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:ErrorDialogManager.java

示例10: attachTo

import android.app.FragmentManager; //导入方法依赖的package包/类
public static void attachTo(Activity activity, Object executionScope, boolean finishAfterDialog, Bundle argumentsForErrorDialog) {
    FragmentManager fm = activity.getFragmentManager();
    HoneycombManagerFragment fragment = (HoneycombManagerFragment) fm.findFragmentByTag(ErrorDialogManager.TAG_ERROR_DIALOG_MANAGER);
    if (fragment == null) {
        fragment = new HoneycombManagerFragment();
        fm.beginTransaction().add(fragment, ErrorDialogManager.TAG_ERROR_DIALOG_MANAGER).commit();
        fm.executePendingTransactions();
    }
    fragment.finishAfterDialog = finishAfterDialog;
    fragment.argumentsForErrorDialog = argumentsForErrorDialog;
    fragment.executionScope = executionScope;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:ErrorDialogManager.java

示例11: addFragment

import android.app.FragmentManager; //导入方法依赖的package包/类
private void addFragment(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.add(R.id.FragmentContainer, fragment, tag);

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

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

示例12: replaceFragment

import android.app.FragmentManager; //导入方法依赖的package包/类
private void replaceFragment(final Fragment fragment, final boolean addToBackStack) {
    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.replace(R.id.FragmentContainer, fragment, tag);

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

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

示例13: onCreate

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.address_book_content);

    final FragmentManager fragmentManager = getFragmentManager();

    walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT);
    sendingAddressesFragment = (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT);

    final FragmentTransaction removal = fragmentManager.beginTransaction();

    if (walletAddressesFragment == null)
        walletAddressesFragment = new WalletAddressesFragment();
    else
        removal.remove(walletAddressesFragment);

    if (sendingAddressesFragment == null)
        sendingAddressesFragment = new SendingAddressesFragment();
    else
        removal.remove(sendingAddressesFragment);

    if (!removal.isEmpty()) {
        removal.commit();
        fragmentManager.executePendingTransactions();
    }

    final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager);
    if (pager != null) {
        pager.setAdapter(
                new TwoFragmentAdapter(fragmentManager, walletAddressesFragment, sendingAddressesFragment));

        final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs);
        pagerTabs.addTabLabels(R.string.address_book_list_receiving_title,
                R.string.address_book_list_sending_title);

        pager.setOnPageChangeListener(pagerTabs);
        final int position = 1;
        pager.setCurrentItem(position);
        pager.setPageMargin(2);
        pager.setPageMarginDrawable(R.color.bg_less_bright);

        pagerTabs.onPageSelected(position);
        pagerTabs.onPageScrolled(position, 0, 0);
    } else {
        fragmentManager.beginTransaction().add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT)
                .add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT).commit();
    }

    updateFragments();
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:53,代码来源:AddressBookActivity.java


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