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


Java FragmentManager.FragmentLifecycleCallbacks方法代码示例

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


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

示例1: registerFragmentCallbacks

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
 * 给每个 Activity 的所有 Fragment 设置监听其生命周期, Activity 可以通过 {@link IActivity#useFragment()}
 * 设置是否使用监听,如果这个 Activity 返回 false 的话,这个 Activity 下面的所有 Fragment 将不能使用 {@link FragmentDelegate}
 * 意味着 {@link BaseFragment} 也不能使用
 *
 * @param activity
 */
private void registerFragmentCallbacks(Activity activity) {
    boolean useFragment = activity instanceof IActivity ? ((IActivity) activity).useFragment() : true;
    if (activity instanceof FragmentActivity && useFragment) {

        if (mFragmentLifecycle == null) {
            mFragmentLifecycle = new FragmentLifecycle();
        }

        ((FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(mFragmentLifecycle, true);

        if (mFragmentLifecycles == null && mExtras.containsKey(ConfigModule.class.getName())) {
            mFragmentLifecycles = new ArrayList<>();
            List<ConfigModule> modules = (List<ConfigModule>) mExtras.get(ConfigModule.class.getName());
            for (ConfigModule module : modules) {
                module.injectFragmentLifecycle(mApplication, mFragmentLifecycles);
            }
            mExtras.remove(ConfigModule.class.getName());
        }

        for (FragmentManager.FragmentLifecycleCallbacks fragmentLifecycle : mFragmentLifecycles) {
            ((FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(fragmentLifecycle, true);
        }
    }
}
 
开发者ID:Superingxz,项目名称:MoligyMvpArms,代码行数:32,代码来源:ActivityLifecycle.java

示例2: registerFragmentCallbacks

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
 * To set the lifecycle of all Fragments settings for each Activity, the Activity can be accessed through {@link IActivity # useFragment ()}
 * Set whether to use the monitor, if the Activity returns false, then the activities of all the following Fragment will not be able to use {@link FragmentDelegate}
 *
 * @param activity: Activity
 */
private void registerFragmentCallbacks(Activity activity) {
    boolean useFragment = !(activity instanceof IActivity) || ((IActivity) activity).useFragment();
    if (activity instanceof FragmentActivity && useFragment) {

        if (mFragmentLifecycle == null) {
            mFragmentLifecycle = new FragmentLifecycle();
        }
        ((FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(mFragmentLifecycle, true);

        if (mFragmentLifecycles == null && mExtras.containsKey(ConfigLifecycle.class.getName())) {
            mFragmentLifecycles = new ArrayList<>();
            List<ConfigLifecycle> lifecycles = (List<ConfigLifecycle>) mExtras.get(ConfigLifecycle.class.getName());
            for (ConfigLifecycle lifecycle : lifecycles) {
                lifecycle.injectFragmentLifecycle(mApplication, mFragmentLifecycles);
            }
            mExtras.remove(ConfigLifecycle.class.getName());
        }

        for (FragmentManager.FragmentLifecycleCallbacks fragmentLifecycle : mFragmentLifecycles) {
            ((FragmentActivity) activity).getSupportFragmentManager()
                    .registerFragmentLifecycleCallbacks(fragmentLifecycle, true);
        }
    }
}
 
开发者ID:goutham106,项目名称:GmArchMvvm,代码行数:31,代码来源:ActivityLifecycle.java

示例3: onActivityDestroyed

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onActivityDestroyed(Activity activity) {
    mAppManager.removeActivity(activity);

    boolean useFragment = activity instanceof IActivity ? ((IActivity) activity).useFragment() : true;
    if (activity instanceof FragmentActivity && useFragment) {
        if (mFragmentLifecycle != null) {
            ((FragmentActivity) activity).getSupportFragmentManager().unregisterFragmentLifecycleCallbacks(mFragmentLifecycle);
        }
        if (mFragmentLifecycles != null && mFragmentLifecycles.size() > 0) {
            for (FragmentManager.FragmentLifecycleCallbacks fragmentLifecycle : mFragmentLifecycles) {
                ((FragmentActivity) activity).getSupportFragmentManager().unregisterFragmentLifecycleCallbacks(fragmentLifecycle);
            }
        }
    }

    ActivityDelegate activityDelegate = fetchActivityDelegate(activity);
    if (activityDelegate != null) {
        activityDelegate.onDestroy();
        activity.getIntent().removeExtra(ActivityDelegate.ACTIVITY_DELEGATE);
    }
}
 
开发者ID:hshare,项目名称:MVPArmsTest1,代码行数:23,代码来源:ActivityLifecycle.java

示例4: registerFragmentCallbacks

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
 * 给每个 Activity 的所有 Fragment 设置监听其生命周期, Activity 可以通过 {@link IActivity#useFragment()}
 * 设置是否使用监听,如果这个 Activity 返回 false 的话,这个 Activity 下面的所有 Fragment 将不能使用 {@link FragmentDelegate}
 *
 * @param activity: Activity
 */
private void registerFragmentCallbacks(Activity activity) {
    boolean useFragment = !(activity instanceof IActivity) || ((IActivity) activity).useFragment();
    if (activity instanceof FragmentActivity && useFragment) {

        if (mFragmentLifecycle == null) {
            mFragmentLifecycle = new FragmentLifecycle();
        }

        ((FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(mFragmentLifecycle, true);

        if (mFragmentLifecycles == null && mExtras.containsKey(ConfigLifecycle.class.getName())) {
            mFragmentLifecycles = new ArrayList<>();
            List<ConfigLifecycle> lifecycles = (List<ConfigLifecycle>) mExtras.get(ConfigLifecycle.class.getName());
            for (ConfigLifecycle lifecycle : lifecycles) {
                lifecycle.injectFragmentLifecycle(mApplication, mFragmentLifecycles);
            }
            mExtras.remove(ConfigLifecycle.class.getName());
        }

        for (FragmentManager.FragmentLifecycleCallbacks fragmentLifecycle : mFragmentLifecycles) {
            ((FragmentActivity) activity).getSupportFragmentManager()
                    .registerFragmentLifecycleCallbacks(fragmentLifecycle, true);
        }
    }
}
 
开发者ID:xiaobailong24,项目名称:MVVMArms,代码行数:32,代码来源:ActivityLifecycle.java

示例5: injectFragmentLifecycle

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void injectFragmentLifecycle(Context context, List<FragmentManager.FragmentLifecycleCallbacks> lifecycles) {
    lifecycles.add(new FragmentManager.FragmentLifecycleCallbacks() {
        @Override
        public void onFragmentDestroyed(FragmentManager fm, Fragment f) {
            ((RefWatcher) ((App) f.getActivity().getApplication()).getAppComponent().extras().get(RefWatcher.class.getName())).watch(this);
        }
    });
}
 
开发者ID:RockyQu,项目名称:MVVMFrames,代码行数:10,代码来源:AppConfiguration.java

示例6: onActivityCreated

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
    if (activity instanceof IActivity && activity.getIntent() != null) {
        ActivityDelegate activityDelegate = getActivityDelegate(activity);
        if (activityDelegate == null) {
            activityDelegate = new ActivityDelegate(activity);
            activity.getIntent().putExtra(ActivityDelegate.ACTIVITY_DELEGATE, activityDelegate);
        }
        activityDelegate.onCreate(savedInstanceState);
    }

    if (activity instanceof FragmentActivity) {
        if (mFragmentLifeCycle == null) {
            mFragmentLifeCycle = new FragmentLifeCycle();
        }
        ((FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(mFragmentLifeCycle, true);
    }

    if (mFragmentLifeCycles == null) {
        mFragmentLifeCycles = new ArrayList<>();
        List<ConfigModule> configModules = (List<ConfigModule>) mExtras.get(ConfigModule.class.getSimpleName());
        for (ConfigModule module : configModules) {
            module.injectFragmentLifeCycles(mApplication, mFragmentLifeCycles);
        }
    }

    for (FragmentManager.FragmentLifecycleCallbacks lifecycleCallbacks : mFragmentLifeCycles) {
        ((FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(lifecycleCallbacks, true);
    }

}
 
开发者ID:harrylefit,项目名称:EazyBaseMVP,代码行数:32,代码来源:ActivityLifeCycle.java

示例7: unregisterFragmentLifecycleCallback

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void unregisterFragmentLifecycleCallback(Activity activity
        , FragmentManager.FragmentLifecycleCallbacks callbacks) {
    if (callbacks != null && activity instanceof FragmentActivity) {
        FragmentManager supportFragmentManager = ((FragmentActivity) activity).getSupportFragmentManager();
        supportFragmentManager.unregisterFragmentLifecycleCallbacks(callbacks);
    }
}
 
开发者ID:aesean,项目名称:ActivityStack,代码行数:8,代码来源:LifecycleUtils.java

示例8: injectFragmentLifecycle

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void injectFragmentLifecycle(Context context, List<FragmentManager.FragmentLifecycleCallbacks> lifecycles) {
    lifecycles.add(new FragmentManager.FragmentLifecycleCallbacks() {
        @Override
        public void onFragmentDestroyed(FragmentManager fm, Fragment f) {

        }
    });
}
 
开发者ID:RockyQu,项目名称:BluetoothKit,代码行数:10,代码来源:AppConfiguration.java

示例9: injectFragmentLifecycle

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void injectFragmentLifecycle(Context context, List<FragmentManager.FragmentLifecycleCallbacks> lifecycles) {
    //向Fragment的生命周期中注入一些自定义逻辑
}
 
开发者ID:GitLqr,项目名称:LQRBiliBlili,代码行数:5,代码来源:GlobalConfiguration.java

示例10: injectFragmentLifecycle

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
 * 使用{@link FragmentManager.FragmentLifecycleCallbacks}在Fragment的生命周期中注入一些操作
 *
 * @param context
 * @param lifecycles
 */
void injectFragmentLifecycle(Context context, List<FragmentManager.FragmentLifecycleCallbacks> lifecycles);
 
开发者ID:RockyQu,项目名称:MVVMFrames,代码行数:8,代码来源:ConfigModule.java

示例11: injectFragmentLifeCycles

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
 * @param context
 * @param fragmentLifecycleCallbacks
 */
void injectFragmentLifeCycles(Context context, List<FragmentManager.FragmentLifecycleCallbacks> fragmentLifecycleCallbacks);
 
开发者ID:harrylefit,项目名称:EazyBaseMVP,代码行数:6,代码来源:ConfigModule.java

示例12: injectFragmentLifecycle

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
 * Use {@link FragmentManager.FragmentLifecycleCallbacks} to inject some actions in the Fragment lifecycle
 *
 * @param context:    Context
 * @param lifecycles: List of FragmentManager.FragmentLifecycleCallbacks
 */
void injectFragmentLifecycle(Context context, List<FragmentManager.FragmentLifecycleCallbacks> lifecycles);
 
开发者ID:goutham106,项目名称:GmArchMvvm,代码行数:8,代码来源:ConfigLifecycle.java

示例13: injectFragmentLifecycle

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
 * 使用 {@link FragmentManager.FragmentLifecycleCallbacks} 在 Fragment 的生命周期中注入一些操作
 *
 * @param context:    Context
 * @param lifecycles: List<FragmentManager.FragmentLifecycleCallbacks>
 */
void injectFragmentLifecycle(Context context, List<FragmentManager.FragmentLifecycleCallbacks> lifecycles);
 
开发者ID:xiaobailong24,项目名称:MVVMArms,代码行数:8,代码来源:ConfigLifecycle.java


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