本文整理匯總了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);