Skip to content

Commit 5655f70

Browse files
author
David Weiser
committed
updates dagger example
1 parent 7bc0767 commit 5655f70

File tree

8 files changed

+31
-57
lines changed

8 files changed

+31
-57
lines changed

com.vogella.android.dagger2simple/app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ android {
2121

2222
dependencies {
2323
compile fileTree(dir: 'libs', include: ['*.jar'])
24-
compile 'com.google.dagger:dagger:2.10'
25-
compile 'com.google.dagger:dagger-android:2.10'
26-
annotationProcessor 'com.google.dagger:dagger-android-processor:2.10'
27-
annotationProcessor 'com.google.dagger:dagger-compiler:2.10'
24+
compile 'com.google.dagger:dagger:2.11'
25+
compile 'com.google.dagger:dagger-android:2.11'
26+
annotationProcessor 'com.google.dagger:dagger-android-processor:2.11'
27+
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
2828
testCompile "junit:junit:4.12"
2929
}

com.vogella.android.dagger2simple/app/src/main/java/com/vogella/android/dagger2simple/MyApplication.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
import android.app.Activity;
44
import android.app.Application;
55

6-
import com.vogella.android.dagger2simple.components.DaggerIApplicationComponent;
7-
86
import javax.inject.Inject;
97

108
import dagger.android.DispatchingAndroidInjector;
11-
import dagger.android.HasDispatchingActivityInjector;
9+
import dagger.android.HasActivityInjector;
1210

13-
public class MyApplication extends Application implements HasDispatchingActivityInjector {
14-
@Inject DispatchingAndroidInjector<Activity> dispatchingAndroidInjector;
11+
public class MyApplication extends Application implements HasActivityInjector {
12+
@Inject
13+
DispatchingAndroidInjector<Activity> dispatchingAndroidInjector;
1514

1615
@Override
1716
public void onCreate() {
1817
super.onCreate();
19-
DaggerIApplicationComponent.create().inject(this);
18+
DaggerMyApplicationComponent.create().inject(this);
2019
}
2120

2221
@Override
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.vogella.android.dagger2simple;
2+
3+
import dagger.Component;
4+
import dagger.android.AndroidInjectionModule;
5+
import dagger.android.AndroidInjector;
6+
7+
@Component(modules = { AndroidInjectionModule.class, MyApplicationModule.class})
8+
public interface MyApplicationComponent extends AndroidInjector<MyApplication> {
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.vogella.android.dagger2simple;
2+
3+
4+
import dagger.Module;
5+
import dagger.Provides;
6+
import dagger.android.ContributesAndroidInjector;
7+
8+
@Module
9+
public abstract class MyApplicationModule {
10+
@ContributesAndroidInjector
11+
abstract MainActivity contributeAcitivityInjector();
12+
}

com.vogella.android.dagger2simple/app/src/main/java/com/vogella/android/dagger2simple/components/IApplicationComponent.java

Lines changed: 0 additions & 12 deletions
This file was deleted.

com.vogella.android.dagger2simple/app/src/main/java/com/vogella/android/dagger2simple/components/IMainActivitySubcomponent.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

com.vogella.android.dagger2simple/app/src/main/java/com/vogella/android/dagger2simple/modules/ActivityModule.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

com.vogella.android.dagger2simple/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.3.1'
8+
classpath 'com.android.tools.build:gradle:2.3.3'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files

0 commit comments

Comments
 (0)