本文整理汇总了Java中dagger.android.support.HasSupportFragmentInjector类的典型用法代码示例。如果您正苦于以下问题:Java HasSupportFragmentInjector类的具体用法?Java HasSupportFragmentInjector怎么用?Java HasSupportFragmentInjector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HasSupportFragmentInjector类属于dagger.android.support包,在下文中一共展示了HasSupportFragmentInjector类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleActivity
import dagger.android.support.HasSupportFragmentInjector; //导入依赖的package包/类
private static void handleActivity(Activity activity) {
if (activity instanceof HasSupportFragmentInjector) {
AndroidInjection.inject(activity);
}
if (activity instanceof FragmentActivity) {
((FragmentActivity) activity).getSupportFragmentManager()
.registerFragmentLifecycleCallbacks(
new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentCreated(FragmentManager fm, Fragment f,
Bundle savedInstanceState) {
if (f instanceof Injectable) {
AndroidSupportInjection.inject(f);
}
}
}, true);
}
}
示例2: handleActivity
import dagger.android.support.HasSupportFragmentInjector; //导入依赖的package包/类
private static void handleActivity(Activity activity) {
if (activity instanceof HasSupportFragmentInjector) {
AndroidInjection.inject(activity);
}
if (activity instanceof FragmentActivity) {
((FragmentActivity) activity).getSupportFragmentManager()
.registerFragmentLifecycleCallbacks(
new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentCreated(FragmentManager fm, Fragment f,
Bundle savedInstanceState) {
if (f instanceof Injectable) {
AndroidSupportInjection.inject(f);
}
}
}, true);
}
}
示例3: handleActivity
import dagger.android.support.HasSupportFragmentInjector; //导入依赖的package包/类
private static void handleActivity(Activity activity) {
if (activity instanceof HasSupportFragmentInjector || activity instanceof Injectable) {
AndroidInjection.inject(activity);
}
if (activity instanceof FragmentActivity) {
((FragmentActivity) activity).getSupportFragmentManager()
.registerFragmentLifecycleCallbacks(
new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentCreated(FragmentManager fm, Fragment f,
Bundle savedInstanceState) {
if (f instanceof Injectable) {
AndroidSupportInjection.inject(f);
}
}
}, true);
}
}
示例4: handleActivity
import dagger.android.support.HasSupportFragmentInjector; //导入依赖的package包/类
/**
* Automated fragment injector
* @param activity provided by ActivityLifecycleCallbacks()
*/
private static void handleActivity(Activity activity){
if(activity instanceof HasSupportFragmentInjector){
AndroidInjection.inject(activity);
}
if(activity instanceof FragmentActivity){
((FragmentActivity) activity).getSupportFragmentManager()
.registerFragmentLifecycleCallbacks(
new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentCreated(
FragmentManager fm, Fragment f, Bundle savedInstanceState) {
if(f instanceof InjectableFragment){
AndroidSupportInjection.inject(f);
}
}
}, true);
}
}
示例5: handleActivity
import dagger.android.support.HasSupportFragmentInjector; //导入依赖的package包/类
private void handleActivity(Activity activity) {
if (activity instanceof HasSupportFragmentInjector) {
// this works because we're using support fragments, so it's okay to setup after Activity.super.onCreate()
// See https://github.com/googlesamples/android-architecture-components/issues/99
AndroidInjection.inject(activity);
}
if (activity instanceof FragmentActivity) {
FragmentActivity fragmentActivity = (FragmentActivity) activity;
fragmentActivity.getSupportFragmentManager().registerFragmentLifecycleCallbacks(new FragmentManager
.FragmentLifecycleCallbacks() {
@Override
public void onFragmentPreAttached(FragmentManager fm, Fragment f, Context context) {
if (f instanceof Injectable) {
AndroidSupportInjection.inject(f);
}
}
}, true);
}
}
示例6: handleActivity
import dagger.android.support.HasSupportFragmentInjector; //导入依赖的package包/类
private static void handleActivity(Activity activity) {
if (activity instanceof HasSupportFragmentInjector) {
AndroidInjection.inject(activity);
}
if (activity instanceof FragmentActivity) {
((FragmentActivity) activity).getSupportFragmentManager()
.registerFragmentLifecycleCallbacks(new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentCreated(FragmentManager fm, Fragment f, Bundle savedInstanceState) {
if (f instanceof Injectable)
AndroidSupportInjection.inject(f);
}
}, true);
}
}
示例7: handleActivity
import dagger.android.support.HasSupportFragmentInjector; //导入依赖的package包/类
private static void handleActivity(Activity activity) {
if (activity instanceof HasSupportFragmentInjector) {
AndroidInjection.inject(activity);
}
if (activity instanceof FragmentActivity) {
((FragmentActivity) activity).getSupportFragmentManager()
.registerFragmentLifecycleCallbacks(
new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentCreated(FragmentManager fm, Fragment f, Bundle savedInstanceState) {
if (f instanceof Injectable) {
AndroidSupportInjection.inject(f);
}
}
}, true);
}
}
示例8: handleActivity
import dagger.android.support.HasSupportFragmentInjector; //导入依赖的package包/类
/**
* The strategy for automated dependency injection is:
*
* If this activity has implemented HasSupportFragmentInjector interfacea which means it has
* to return the DispatchInjector through overriding public AndroidInjector<Fragment>
* fragmentInjector() method to return the @Inject DispatchInjector. Then this activity must
* be processed with the AndroidInjection by calling the AndroidInjection.inject method.
*
* If the activity is extended from the FragmentActivity, then we will set up the dependency
* injection for all the fragments by instrumenting the AndroidInjection.inject method at
* the beginning of fragment's creation. Since the fragment takes the main responsibility on
* UI rendering.
*
* @param activity activity to be processed.
*/
private static void handleActivity(Activity activity) {
// TODO: an injectable for activity separately
if (activity instanceof HasSupportFragmentInjector) {
// When the activity has implemented the HasSupportFragmentInjector interface, android
// injector will inject into it, so the activity can be injected with the dispatch
// injector specific for fragment. Then this dispatch injector will be returned through
// the override method and contribute to android injector factory for fragment
AndroidInjection.inject(activity);
}
if (activity instanceof FragmentActivity) {
((FragmentActivity) activity).getSupportFragmentManager()
.registerFragmentLifecycleCallbacks(
new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentCreated(FragmentManager fm, Fragment f,
Bundle savedInstanceState) {
if (f instanceof Injectable) {
// The injector only contains the provision method for the
// field in the fragment.
// But for activity, there will be a module providing the
// binding method which will be bound to the fragment's
// subcomponent's builder (Android injector builder) and
// then be cast to AndroidInjector.Factory
AndroidSupportInjection.inject(f);
}
}
}, true);
}
}