本文整理汇总了Java中android.support.v4.app.FragmentManager.findFragmentByTag方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentManager.findFragmentByTag方法的具体用法?Java FragmentManager.findFragmentByTag怎么用?Java FragmentManager.findFragmentByTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.FragmentManager
的用法示例。
在下文中一共展示了FragmentManager.findFragmentByTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showRefreshDurationDialog
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public static void showRefreshDurationDialog(FragmentManager fm, int rotateTime, boolean isMinute) {
FragmentTransaction ft = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag(TAG);
if (prev != null) {
ft.remove(prev);
}
ft.add(newInstance(rotateTime, isMinute), TAG)
.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
try {
ft.commit();
} catch (IllegalStateException e) {
ft.commitAllowingStateLoss();
}
}
示例2: executeDebouncePop
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void executeDebouncePop(FragmentManager fm) {
Fragment popF = fm.findFragmentByTag(fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName());
if (popF instanceof ISupportFragment) {
ISupportFragment supportF = (ISupportFragment) popF;
if (supportF.getSupportDelegate().mIsSharedElement) {
long now = System.currentTimeMillis();
if (now < mShareElementDebounceTime) {
mShareElementDebounceTime = System.currentTimeMillis() + supportF.getSupportDelegate().mAnimHelper.exitAnim.getDuration();
return;
}
}
mShareElementDebounceTime = System.currentTimeMillis() + supportF.getSupportDelegate().mAnimHelper.exitAnim.getDuration();
}
fm.popBackStack();
}
示例3: onBackPressed
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
FragmentManager supportFragmentManager = view.getMainActivity().getSupportFragmentManager();
Fragment fragment = supportFragmentManager.findFragmentByTag(TYPE_LIST_TAG);
if (listFragment == null && collectionFragment != null && !collectionFragment.isHidden()) {
view.setToolBar();
supportFragmentManager.beginTransaction().remove(collectionFragment).commit();
onMainDestroy();
return;
}
if (fragment != null && fragment.isHidden()) {
setSelectFragment(TYPE_LIST_TAG);
} else {
view.onBack();
}
}
示例4: onCreate
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ActionBar actionbar = getSupportActionBar();
actionbar.setDisplayHomeAsUpEnabled(true);
actionbar.setHomeButtonEnabled(true);
actionbar.setTitle(getIntent().getExtras().getString(
Constants.PARAM_NAME));
final FragmentManager fm = getSupportFragmentManager();
Fragment f = fm.findFragmentByTag(GraphFragment.TAG);
final FragmentTransaction ft = fm.beginTransaction();
if (f == null) {
f = GraphFragment.newInstance();
f.setArguments(getIntent().getExtras());
ft.add(android.R.id.content, f, GraphFragment.TAG);
} else {
ft.attach(f);
}
ft.commit();
}
示例5: showAlipayDialog
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@TargetApi(17)
private void showAlipayDialog(boolean notOpenFlag) {
FragmentManager fm = getSupportFragmentManager();
if (fm != null && getActivity() != null && !getActivity().isDestroyed()) {
FragmentTransaction ft = fm.beginTransaction();
this.mAlipayAutoPayDialog = (AlipayAutoPayDialog) fm.findFragmentByTag("showmAlipayPayDialog");
Bundle bundle = new Bundle();
bundle.putBoolean(AlipayConstant.NOT_OPEN_CONTINUE_MONTHLY, notOpenFlag);
bundle.putBoolean(AlipayConstant.IS_MOBILE_VIP_FLAG, this.mIsMobileVipFlag);
if (this.mAlipayAutoPayDialog == null) {
this.mAlipayAutoPayDialog = new AlipayAutoPayDialog();
} else {
ft.remove(this.mAlipayAutoPayDialog);
}
this.mAlipayAutoPayDialog.setAlipayConfirmCallback(this);
if (this.mAlipayAutoPayDialog.getArguments() == null) {
this.mAlipayAutoPayDialog.setArguments(bundle);
}
ft.add(this.mAlipayAutoPayDialog, "showmAlipayPayDialog");
ft.commitAllowingStateLoss();
}
}
示例6: getRestoreFragment
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* 显示内存重启后的恢复的Fragment
*/
private void getRestoreFragment() {
mFragmentList = new ArrayList<>();
FragmentManager fm = getSupportFragmentManager();
if (fm.findFragmentByTag(HomeFragment.TAG_HOME) == null) {
mFragmentList.add(HomeFragment.newInstance());
} else {
mFragmentList.add((HomeFragment) fm.findFragmentByTag(HomeFragment.TAG_HOME));
}
if (fm.findFragmentByTag(CategoryFragment.TAG_CATEGORY) == null) {
mFragmentList.add(CategoryFragment.newInstance());
} else {
mFragmentList.add((CategoryFragment) fm.findFragmentByTag(CategoryFragment.TAG_CATEGORY));
}
if (fm.findFragmentByTag(CartFragment.TAG_CART) == null) {
mFragmentList.add(CartFragment.newInstance());
} else {
mFragmentList.add((CartFragment) fm.findFragmentByTag(CartFragment.TAG_CART));
}
if (fm.findFragmentByTag(MineFragment.TAG_MINE) == null) {
mFragmentList.add(MineFragment.newInstance());
} else {
mFragmentList.add((MineFragment) fm.findFragmentByTag(MineFragment.TAG_MINE));
}
}
示例7: initContainers
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void initContainers() {
FragmentManager fm = getSupportFragmentManager();
usersTabFragment = (TabContainerFragment) fm.findFragmentByTag(Screens.USERS_TAB);
if (usersTabFragment == null) {
usersTabFragment = TabContainerFragment.newInstance(Screens.USERS_TAB);
fm.beginTransaction()
.add(R.id.master_frame, usersTabFragment, Screens.USERS_TAB)
.detach(usersTabFragment).commitNow();
}
placesTabFragment = (TabContainerFragment) fm.findFragmentByTag(Screens.PLACES_TAB);
if (placesTabFragment == null) {
placesTabFragment = TabContainerFragment.newInstance(Screens.PLACES_TAB);
fm.beginTransaction()
.add(R.id.master_frame, placesTabFragment, Screens.PLACES_TAB)
.detach(placesTabFragment).commitNow();
}
favoritesTabFragment = (TabContainerFragment) fm.findFragmentByTag(Screens.FAVORITES_TAB);
if (favoritesTabFragment == null) {
favoritesTabFragment = TabContainerFragment.newInstance(Screens.FAVORITES_TAB);
fm.beginTransaction()
.add(R.id.master_frame, favoritesTabFragment, Screens.FAVORITES_TAB)
.detach(favoritesTabFragment).commitNow();
}
}
示例8: getRxFacebookAuthFragment
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* Get instance of RxSmartLockPasswordsFragment
*
* @return a RxSmartLockPasswordsFragment
*/
private RxSmartLockPasswordsFragment getRxFacebookAuthFragment(Builder builder) {
FragmentManager fragmentManager = mActivity.getSupportFragmentManager();
// prevent fragment manager already executing transaction
int stackCount = fragmentManager.getBackStackEntryCount();
if( fragmentManager.getFragments() != null )
fragmentManager = fragmentManager.getFragments().get( stackCount > 0 ? stackCount-1 : stackCount ).getChildFragmentManager();
RxSmartLockPasswordsFragment rxSmartLockPasswordsFragment = (RxSmartLockPasswordsFragment)
fragmentManager.findFragmentByTag(RxSmartLockPasswordsFragment.TAG);
if (rxSmartLockPasswordsFragment == null) {
rxSmartLockPasswordsFragment = RxSmartLockPasswordsFragment.newInstance(builder);
fragmentManager
.beginTransaction()
.add(rxSmartLockPasswordsFragment, RxSmartLockPasswordsFragment.TAG)
.commit();
fragmentManager.executePendingTransactions();
}
return rxSmartLockPasswordsFragment;
}
示例9: dismissDialog
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public void dismissDialog() {
final FragmentManager fm = getFragmentManager();
if (fm == null)
return;
Fragment prev = fm.findFragmentByTag("cadfragment");
if (prev != null) {
DialogFragment df = (DialogFragment) prev;
df.dismiss();
}
}
示例10: getDisplayedQuery
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public static String getDisplayedQuery(FragmentManager fragmentManager) {
Fragment qf = fragmentManager.findFragmentByTag(SearchFragment.FRAGMENT_TAG);
Fragment af = fragmentManager.findFragmentByTag(AgendaFragment.FRAGMENT_TAG);
if (qf != null && qf.isVisible()) {
return ((SearchFragment) qf).getQuery();
} else if (af != null && af.isVisible()) {
return ((AgendaFragment) af).getQuery();
}
return null;
}
示例11: findHolderFragment
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private static HolderFragment findHolderFragment(FragmentManager manager) {
if (manager.isDestroyed()) {
throw new IllegalStateException("Can't access LifecycleModels from onDestroy");
}
Fragment fragmentByTag = manager.findFragmentByTag(HOLDER_TAG);
if (fragmentByTag != null && !(fragmentByTag instanceof HolderFragment)) {
throw new IllegalStateException("Unexpected "
+ "fragment instance was returned by HOLDER_TAG");
}
return (HolderFragment) fragmentByTag;
}
示例12: findStackFragment
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* find Fragment from FragmentStack
*/
@SuppressWarnings("unchecked")
<T extends SupportFragment> T findStackFragment(Class<T> fragmentClass, String toFragmentTag, FragmentManager fragmentManager) {
fragmentManager = checkFragmentManager(fragmentManager, null);
if (fragmentManager == null) return null;
Fragment fragment = null;
if (toFragmentTag == null) {
// 如果是 查找Fragment时,则有可能是在FragmentPagerAdapter,这种情况下,
// 它们的Tag是以android:switcher开头,所以这里我们使用下面的方式
List<Fragment> fragmentList = fragmentManager.getFragments();
if (fragmentList == null) return null;
int sizeChildFrgList = fragmentList.size();
for (int i = sizeChildFrgList - 1; i >= 0; i--) {
Fragment brotherFragment = fragmentList.get(i);
if (brotherFragment instanceof SupportFragment && brotherFragment.getClass().getName().equals(fragmentClass.getName())) {
fragment = brotherFragment;
break;
}
}
} else {
fragment = fragmentManager.findFragmentByTag(toFragmentTag);
}
if (fragment == null) {
return null;
}
return (T) fragment;
}
示例13: onBackPressed
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
FragmentManager fragmentManager = getSupportFragmentManager();
Fragment fragment = fragmentManager.findFragmentByTag(AboutFragment.TAG);
if (fragment == null) {
super.onBackPressed();
} else {
onFragmentDetached(AboutFragment.TAG);
}
}
示例14: showHomeList
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void showHomeList() {
FragmentManager fragmentManager = getSupportFragmentManager();
Fragment homeListFragment = fragmentManager.findFragmentByTag(HomeListFragment.TAG);
if (homeListFragment == null) {
fragmentManager.beginTransaction()
.add(R.id.main_content, new HomeListFragment(), HomeListFragment.TAG)
.commit();
}
}
示例15: removeSupportFragment
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* Removes the fragment with the given tag.
*
* @param fragmentManager A fragment manager which manages the fragment removal.
* @param tag A tag of the fragment that must be removed.
*/
@SuppressWarnings("WeakerAccess")
public static void removeSupportFragment(@NonNull final FragmentManager fragmentManager,
@NonNull final String tag) {
final Fragment fragment = fragmentManager.findFragmentByTag(tag);
if (fragment != null) {
fragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss();
}
}