本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
});
}
示例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);
}
}
示例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);
}
}
示例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) {
}
});
}
示例9: injectFragmentLifecycle
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void injectFragmentLifecycle(Context context, List<FragmentManager.FragmentLifecycleCallbacks> lifecycles) {
//向Fragment的生命周期中注入一些自定义逻辑
}
示例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);
示例11: injectFragmentLifeCycles
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* @param context
* @param fragmentLifecycleCallbacks
*/
void injectFragmentLifeCycles(Context context, List<FragmentManager.FragmentLifecycleCallbacks> fragmentLifecycleCallbacks);
示例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);
示例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);