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