Skip to content

Instantly share code, notes, and snippets.

View vestrel00's full-sized avatar
👨‍💻
Working, life, and the universe!

Vandolf Estrellado vestrel00

👨‍💻
Working, life, and the universe!
View GitHub Profile
@vestrel00
vestrel00 / build.gradle
Created July 25, 2017 19:17
A: 2 - app/build.gradle
dependencies {
def daggerVersion = '2.11'
annotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"
annotationProcessor "com.google.dagger:dagger-android-processor:$daggerVersion"
compile "com.google.dagger:dagger:$daggerVersion"
compile "com.google.dagger:dagger-android:$daggerVersion"
}
@vestrel00
vestrel00 / PerActivity.java
Last active July 26, 2017 14:16
A: 3 - inject/PerActivity.java
@Scope
@Retention(RetentionPolicy.RUNTIME)
public @interface PerActivity {
}
@vestrel00
vestrel00 / PerFragment.java
Last active July 26, 2017 14:16
A: 3 - inject/PerFragment.java
@Scope
@Retention(RetentionPolicy.RUNTIME)
public @interface PerFragment {
}
@vestrel00
vestrel00 / PerChildFragment.java
Last active July 26, 2017 14:16
A: 3 - inject/PerChildFragment.java
@Scope
@Retention(RetentionPolicy.RUNTIME)
public @interface PerChildFragment {
}
@vestrel00
vestrel00 / App.java
Created July 26, 2017 11:50
A: 3 - App.java
public class App extends Application implements HasActivityInjector {
@Inject
DispatchingAndroidInjector<Activity> activityInjector;
@Override
public void onCreate() {
super.onCreate();
DaggerAppComponent.create().inject(this);
}
@vestrel00
vestrel00 / AppModule.java
Created July 26, 2017 14:02
A: 3 - AppModule.java
@Module(includes = AndroidInjectionModule.class)
abstract class AppModule {
}
@vestrel00
vestrel00 / AppComponent.java
Created July 26, 2017 14:14
A: 3 - AppComponent.java
@Singleton
@Component(modules = AppModule.class)
interface AppComponent {
void inject(App app);
}
@vestrel00
vestrel00 / BaseActivity.java
Last active July 31, 2017 13:55
A: 3 - ui/common/BaseActivity.java
public abstract class BaseActivity extends Activity implements HasFragmentInjector {
@Inject
@Named(BaseActivityModule.ACTIVITY_FRAGMENT_MANAGER)
protected FragmentManager fragmentManager;
@Inject
DispatchingAndroidInjector<Fragment> fragmentInjector;
@Override
@vestrel00
vestrel00 / BaseActivityModule.java
Created July 26, 2017 14:44
A: 3 - ui/common/BaseActivityModule.java
@Module
public abstract class BaseActivityModule {
static final String ACTIVITY_FRAGMENT_MANAGER = "BaseActivityModule.activityFragmentManager";
@Binds
@PerActivity
abstract Context activityContext(Activity activity);
@Provides
@vestrel00
vestrel00 / BaseFragment.java
Last active April 27, 2018 17:15
A: 3 - ui/common/BaseFragment.java
public abstract class BaseFragment extends Fragment implements HasFragmentInjector {
@Inject
protected Context activityContext;
// Note that this should not be used within a child fragment.
@Inject
@Named(BaseFragmentModule.CHILD_FRAGMENT_MANAGER)
protected FragmentManager childFragmentManager;