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


Java Fragment.getArguments方法代码示例

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


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

示例1: getDefaultScreenGettingFunction

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public static <ScreenT extends Screen> Function<Fragment, ScreenT> getDefaultScreenGettingFunction(final Class<ScreenT> screenClass) {
	return new Function<Fragment, ScreenT>() {
		@Override
		@SuppressWarnings("unchecked")
		public ScreenT call(Fragment fragment) {
			if (fragment.getArguments() == null) {
				throw new IllegalArgumentException("Fragment has no arguments.");
			} else if (Serializable.class.isAssignableFrom(screenClass)) {
				return (ScreenT) fragment.getArguments().getSerializable(KEY_SCREEN);
			} else if (Parcelable.class.isAssignableFrom(screenClass)) {
				return (ScreenT) fragment.getArguments().getParcelable(KEY_SCREEN);
			} else {
				throw new IllegalArgumentException("Screen " + screenClass.getSimpleName() + " should be Serializable or Parcelable.");
			}
		}
	};
}
 
开发者ID:aartikov,项目名称:Alligator,代码行数:18,代码来源:FragmentConverter.java

示例2: replaceFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 替换fragment
 *
 * @param srcFragment   源fragment
 * @param destFragment  目标fragment
 * @param isAddStack    是否入回退栈
 * @param sharedElement 共享元素
 * @return 目标fragment
 */
public static Fragment replaceFragment(@NonNull final Fragment srcFragment,
                                       @NonNull final Fragment destFragment,
                                       final boolean isAddStack,
                                       final SharedElement... sharedElement) {
    if (srcFragment.getArguments() == null) return null;
    int containerId = srcFragment.getArguments().getInt(ARGS_ID);
    if (containerId == 0) return null;
    return replaceFragment(srcFragment.getFragmentManager(), destFragment, containerId, isAddStack, sharedElement);
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:19,代码来源:FragmentUtils.java

示例3: replaceFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 替换fragment
 *
 * @param srcFragment  源fragment
 * @param destFragment 目标fragment
 * @param isAddStack   是否入回退栈
 * @return 目标fragment
 */
public static Fragment replaceFragment(@NonNull Fragment srcFragment,
                                       @NonNull Fragment destFragment,
                                       boolean isAddStack) {
    if (srcFragment.getArguments() == null) return null;
    int containerId = srcFragment.getArguments().getInt(ARGS_ID);
    if (containerId == 0) return null;
    return replaceFragment(srcFragment.getFragmentManager(), destFragment, containerId, isAddStack);
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:17,代码来源:FragmentUtils.java

示例4: onFragmentStopped

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void onFragmentStopped(FragmentManager fm, Fragment f) {
    Bundle savedState = savedStates.remove(f);
    if (savedState != null) {
        String message = f.getClass().getSimpleName() + ".onSaveInstanceState wrote: " + TooLargeTool.bundleBreakdown(savedState);
        if (f.getArguments() != null) {
            message += "\n* fragment arguments = " + TooLargeTool.bundleBreakdown(f.getArguments());
        }
        log(message);
    }
}
 
开发者ID:guardian,项目名称:toolargetool,代码行数:12,代码来源:FragmentSavedStateLogger.java

示例5: fetchFragmentDelegate

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private FragmentDelegate fetchFragmentDelegate(Fragment fragment) {
    if (fragment instanceof IFragment && fragment.getArguments() != null) {
        fragment.getArguments().setClassLoader(getClass().getClassLoader());
        return fragment.getArguments().getParcelable(FragmentDelegate.FRAGMENT_DELEGATE);
    }
    return null;
}
 
开发者ID:goutham106,项目名称:GmArchMvvm,代码行数:8,代码来源:FragmentLifecycle.java

示例6: getArgs

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 获取参数
 *
 * @param fragment fragment
 */
private static Args getArgs(@NonNull Fragment fragment) {
    Bundle bundle = fragment.getArguments();
    if (bundle == null || bundle.getInt(ARGS_ID) == 0) {
        return null;
    }
    return new Args(bundle.getInt(ARGS_ID), bundle.getBoolean(ARGS_IS_HIDE), bundle.getBoolean(ARGS_IS_ADD_STACK));
}
 
开发者ID:xiaobailong24,项目名称:MVVMArms,代码行数:13,代码来源:FragmentUtils.java

示例7: getArgs

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 获取参数
 *
 * @param fragment fragment
 */
private static Args getArgs(@NonNull Fragment fragment) {
    Bundle bundle = fragment.getArguments();
    if (bundle == null || bundle.getInt(ARGS_ID) == 0)
        return null;
    return new Args(bundle.getInt(ARGS_ID), bundle.getBoolean(ARGS_IS_HIDE), bundle.getBoolean(ARGS_IS_ADD_STACK));
}
 
开发者ID:yangxp108,项目名称:MVPArms_Fragment-fragment,代码行数:12,代码来源:FragmentUtils.java

示例8: handleResultRecord

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
void handleResultRecord(Fragment from) {
    SupportFragment preFragment = getPreFragment(from);
    if (preFragment == null) return;

    Bundle args = from.getArguments();
    if (args == null || !args.containsKey(FRAGMENTATION_ARG_RESULT_RECORD)) return;

    ResultRecord resultRecord = args.getParcelable(FRAGMENTATION_ARG_RESULT_RECORD);
    if (resultRecord == null) return;

    preFragment.onFragmentResult(resultRecord.requestCode, resultRecord.resultCode, resultRecord.resultBundle);
}
 
开发者ID:LonelyMushroom,项目名称:aarLibrary,代码行数:13,代码来源:FragmentationDelegate.java

示例9: getArgs

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * Get the parameters
 *
 * @param fragment fragment
 */
private static Args getArgs(@NonNull Fragment fragment) {
    Bundle bundle = fragment.getArguments();
    if (bundle == null || bundle.getInt(ARGS_ID) == 0)
        return null;
    return new Args(bundle.getInt(ARGS_ID), bundle.getBoolean(ARGS_IS_HIDE), bundle.getBoolean(ARGS_IS_ADD_STACK));
}
 
开发者ID:goutham106,项目名称:GmArchMvvm,代码行数:12,代码来源:FragmentUtils.java

示例10: onFragmentAttached

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void onFragmentAttached(FragmentManager fm, Fragment f, Context context) {
    super.onFragmentAttached(fm, f, context);
    if (f instanceof IFragment && f.getArguments() != null) {
        FragmentDelegate delegate = getFragmentDelegate(f);
        if (delegate == null) {
            delegate = new FragmentDelegate(f);
            f.getArguments().putSerializable(FragmentDelegate.FRAGMENT_LIFECYCLE, delegate);
        }
        delegate.onAttach(context);
    }
}
 
开发者ID:harrylefit,项目名称:EazyBaseMVP,代码行数:13,代码来源:FragmentLifeCycle.java

示例11: replaceFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 替换fragment
 *
 * @param srcFragment   源fragment
 * @param destFragment  目标fragment
 * @param isAddStack    是否入回退栈
 * @param sharedElement 共享元素
 * @return 目标fragment
 */
public static Fragment replaceFragment(@NonNull Fragment srcFragment,
                                       @NonNull Fragment destFragment,
                                       boolean isAddStack,
                                       SharedElement... sharedElement) {
    if (srcFragment.getArguments() == null) return null;
    int containerId = srcFragment.getArguments().getInt(ARGS_ID);
    if (containerId == 0) return null;
    return replaceFragment(srcFragment.getFragmentManager(), destFragment, containerId, isAddStack, sharedElement);
}
 
开发者ID:pan2yong22,项目名称:AndroidUtilCode-master,代码行数:19,代码来源:FragmentUtils.java

示例12: getArgs

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 获取参数
 *
 * @param fragment fragment
 */
private static Args getArgs(@NonNull final Fragment fragment) {
    Bundle bundle = fragment.getArguments();
    if (bundle == null || bundle.getInt(ARGS_ID) == 0) return null;
    return new Args(bundle.getInt(ARGS_ID), bundle.getBoolean(ARGS_IS_HIDE), bundle.getBoolean(ARGS_IS_ADD_STACK));
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:11,代码来源:FragmentUtils.java

示例13: operateFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 操作fragment
 *
 * @param fragmentManager fragment管理器
 * @param srcFragment     源fragment
 * @param destFragment    目标fragment
 * @param type            操作类型
 * @param sharedElements  共享元素
 * @return destFragment
 */
private static Fragment operateFragment(@NonNull final FragmentManager fragmentManager,
                                        final Fragment srcFragment,
                                        @NonNull Fragment destFragment,
                                        final int type,
                                        final SharedElement... sharedElements) {
    if (srcFragment == destFragment) return null;
    if (srcFragment != null && srcFragment.isRemoving()) {
        Log.e("FragmentUtils", srcFragment.getClass().getName() + " is isRemoving");
        return null;
    }
    String name = destFragment.getClass().getName();
    Bundle args = destFragment.getArguments();

    FragmentTransaction ft = fragmentManager.beginTransaction();
    if (sharedElements == null || sharedElements.length == 0) {
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    } else {
        for (SharedElement element : sharedElements) {// 添加共享元素动画
            ft.addSharedElement(element.sharedElement, element.name);
        }
    }
    switch (type) {
        case TYPE_ADD_HIDE_FRAGMENT:
            ft.hide(srcFragment);
        case TYPE_ADD_FRAGMENT:
            Fragment fragmentByTag = fragmentManager.findFragmentByTag(name);
            if (fragmentByTag != null) {
                if (fragmentByTag.isAdded()) {
                    ft.remove(fragmentByTag);
                }
            }
            ft.add(args.getInt(ARGS_ID), destFragment, name);
            if (args.getBoolean(ARGS_IS_HIDE)) ft.hide(destFragment);
            if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
            break;
        case TYPE_REMOVE_FRAGMENT:
            ft.remove(destFragment);
            break;
        case TYPE_REMOVE_TO_FRAGMENT:
            List<Fragment> fragments = getFragments(fragmentManager);
            for (int i = fragments.size() - 1; i >= 0; --i) {
                Fragment fragment = fragments.get(i);
                if (fragment == destFragment) {
                    if (srcFragment != null) ft.remove(fragment);
                    break;
                }
                ft.remove(fragment);
            }
            break;
        case TYPE_REPLACE_FRAGMENT:
            ft.replace(args.getInt(ARGS_ID), destFragment, name);
            if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
            break;
        case TYPE_ADD_POP_FRAGMENT:
            popFragment(fragmentManager);
            ft.add(args.getInt(ARGS_ID), destFragment, name);
            if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
            break;
        case TYPE_HIDE_FRAGMENT:
            ft.hide(destFragment);
            break;
        case TYPE_SHOW_FRAGMENT:
            ft.show(destFragment);
            break;
        case TYPE_SHOW_HIDE_FRAGMENT:
            ft.hide(srcFragment).show(destFragment);
            break;
    }
    ft.commitAllowingStateLoss();
    return destFragment;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:82,代码来源:FragmentUtils.java

示例14: getArgs

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 获取参数
 *
 * @param fragment fragment
 */
private static Args getArgs(@NonNull Fragment fragment) {
    Bundle bundle = fragment.getArguments();
    if (bundle == null || bundle.getInt(ARGS_ID) == 0) return null;
    return new Args(bundle.getInt(ARGS_ID), bundle.getBoolean(ARGS_IS_HIDE), bundle.getBoolean(ARGS_IS_ADD_STACK));
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:11,代码来源:FragmentUtils.java

示例15: fetchFragmentDelegate

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private FragmentDelegate fetchFragmentDelegate(Fragment fragment) {
    if (fragment instanceof IFragment) {
        return fragment.getArguments() == null ? null : fragment.getArguments().getParcelable(FragmentDelegate.FRAGMENT_DELEGATE);
    }
    return null;
}
 
开发者ID:hshare,项目名称:MVPArmsTest1,代码行数:7,代码来源:ActivityLifecycle.java


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