Last active
July 31, 2017 13:55
-
-
Save vestrel00/206ef2d1d66e4adf1e41f3c07ed1909d to your computer and use it in GitHub Desktop.
A: 3 - ui/common/BaseActivity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class BaseActivity extends Activity implements HasFragmentInjector { | |
@Inject | |
@Named(BaseActivityModule.ACTIVITY_FRAGMENT_MANAGER) | |
protected FragmentManager fragmentManager; | |
@Inject | |
DispatchingAndroidInjector<Fragment> fragmentInjector; | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
AndroidInjection.inject(this); | |
super.onCreate(savedInstanceState); | |
} | |
@Override | |
public final AndroidInjector<Fragment> fragmentInjector() { | |
return fragmentInjector; | |
} | |
protected final void addFragment(@IdRes int containerViewId, Fragment fragment) { | |
fragmentManager.beginTransaction() | |
.add(containerViewId, fragment) | |
.commit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment