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