├── hello-dagger1-simple
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── dimens.xml
│ │ │ │ │ └── styles.xml
│ │ │ │ ├── values-w820dp
│ │ │ │ │ └── dimens.xml
│ │ │ │ ├── menu
│ │ │ │ │ └── menu_main.xml
│ │ │ │ └── layout
│ │ │ │ │ └── activity_main.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── codeblast
│ │ │ │ │ └── hellodagger1
│ │ │ │ │ ├── TimeService.java
│ │ │ │ │ ├── HelloPresenter.java
│ │ │ │ │ ├── MessageSupplier.java
│ │ │ │ │ ├── HelloView.java
│ │ │ │ │ ├── TimeServiceImpl.java
│ │ │ │ │ ├── MyApplication.java
│ │ │ │ │ ├── HelloPresenterImpl.java
│ │ │ │ │ ├── RootModule.java
│ │ │ │ │ ├── HelloModule.java
│ │ │ │ │ ├── MessageSupplierImpl.java
│ │ │ │ │ └── MainActivity.java
│ │ │ └── AndroidManifest.xml
│ │ ├── androidTest
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── codeblast
│ │ │ │ └── hellodagger1
│ │ │ │ └── ApplicationTest.java
│ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── codeblast
│ │ │ └── hellodagger1
│ │ │ ├── MyTestRunner.java
│ │ │ └── MainActivityTest.java
│ ├── proguard-rules.pro
│ ├── build.gradle
│ └── app.iml
├── settings.gradle
├── .gitignore
├── README.md
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── build.gradle
├── hello-dagger1-simple.iml
├── gradle.properties
├── gradlew.bat
└── gradlew
├── hello-dagger2-simple
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── codeblast
│ │ │ │ │ └── hellodagger2
│ │ │ │ │ ├── TimeService.java
│ │ │ │ │ ├── HelloPresenter.java
│ │ │ │ │ ├── MessageSupplier.java
│ │ │ │ │ ├── HelloView.java
│ │ │ │ │ ├── HelloComponent.java
│ │ │ │ │ ├── ActivityScope.java
│ │ │ │ │ ├── TimeServiceImpl.java
│ │ │ │ │ ├── HelloPresenterImpl.java
│ │ │ │ │ ├── HelloModule.java
│ │ │ │ │ ├── MessageSupplierImpl.java
│ │ │ │ │ └── HelloActivity.java
│ │ │ ├── res
│ │ │ │ ├── drawable-hdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── drawable-mdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── drawable-xhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── drawable-xxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── values
│ │ │ │ │ ├── styles.xml
│ │ │ │ │ ├── dimens.xml
│ │ │ │ │ └── strings.xml
│ │ │ │ ├── values-w820dp
│ │ │ │ │ └── dimens.xml
│ │ │ │ ├── menu
│ │ │ │ │ └── menu_hello.xml
│ │ │ │ └── layout
│ │ │ │ │ └── activity_hello.xml
│ │ │ └── AndroidManifest.xml
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── codeblast
│ │ │ └── hellodagger2
│ │ │ ├── MessageSupplierTest.java
│ │ │ └── HelloActivityTest.java
│ ├── proguard-rules.pro
│ ├── build.gradle
│ └── app.iml
├── settings.gradle
├── .gitignore
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── README.md
├── build.gradle
├── hello-dagger2-simple.iml
├── gradle.properties
├── gradlew.bat
└── gradlew
├── README.md
└── .gitignore
/hello-dagger1-simple/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/README.md:
--------------------------------------------------------------------------------
1 | For comparison between Dagger1 and Dagger2, this app implements the same functionality as hello-dagger-2 but using Dagger 1...
2 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glombard/hello-dagger2/HEAD/hello-dagger1-simple/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/hello-dagger2-simple/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glombard/hello-dagger2/HEAD/hello-dagger2-simple/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glombard/hello-dagger2/HEAD/hello-dagger1-simple/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glombard/hello-dagger2/HEAD/hello-dagger1-simple/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/java/com/codeblast/hellodagger1/TimeService.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | public interface TimeService {
4 | int currentHour();
5 | }
6 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glombard/hello-dagger2/HEAD/hello-dagger1-simple/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glombard/hello-dagger2/HEAD/hello-dagger1-simple/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/java/com/codeblast/hellodagger2/TimeService.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger2;
2 |
3 | public interface TimeService {
4 | int currentHour();
5 | }
6 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glombard/hello-dagger2/HEAD/hello-dagger2-simple/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glombard/hello-dagger2/HEAD/hello-dagger2-simple/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glombard/hello-dagger2/HEAD/hello-dagger2-simple/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glombard/hello-dagger2/HEAD/hello-dagger2-simple/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/java/com/codeblast/hellodagger1/HelloPresenter.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | public interface HelloPresenter {
4 | void requestMessage();
5 | }
6 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/java/com/codeblast/hellodagger1/MessageSupplier.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | public interface MessageSupplier {
4 | String getMessage();
5 | }
6 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/java/com/codeblast/hellodagger2/HelloPresenter.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger2;
2 |
3 | public interface HelloPresenter {
4 | void requestMessage();
5 | }
6 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/java/com/codeblast/hellodagger2/MessageSupplier.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger2;
2 |
3 | public interface MessageSupplier {
4 | String getMessage();
5 | }
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Dagger 2.0 on Android
2 |
3 | Goals:
4 | - Use Dagger 2.0 for dependency injection
5 | - Keep all the code unit testable
6 | - Use the MVP pattern to separate view logic from the Activity
7 |
8 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/java/com/codeblast/hellodagger1/HelloView.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | public interface HelloView {
4 | void onMessageUpdated(String message);
5 | }
6 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/java/com/codeblast/hellodagger2/HelloView.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger2;
2 |
3 | public interface HelloView {
4 | void onMessageUpdated(String message);
5 | }
6 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/README.md:
--------------------------------------------------------------------------------
1 | # Dagger 2.0 on Android
2 |
3 | Goals:
4 | - Use Dagger 2.0 for dependency injection
5 | - Keep all the code unit testable
6 | - Use the MVP pattern to separate view logic from the Activity
7 |
8 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | HelloDagger1
3 |
4 | Dagger 1 test starting!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
7 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | HelloDagger2
5 | Waiting for message...
6 | Settings
7 |
8 |
9 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/java/com/codeblast/hellodagger2/HelloComponent.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger2;
2 |
3 | import dagger.Component;
4 |
5 | @ActivityScope
6 | @Component(modules = HelloModule.class)
7 | public interface HelloComponent {
8 | void initialize(HelloActivity helloActivity);
9 | }
10 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/java/com/codeblast/hellodagger2/ActivityScope.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger2;
2 |
3 | import java.lang.annotation.Retention;
4 |
5 | import javax.inject.Scope;
6 |
7 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
8 |
9 | @Scope
10 | @Retention(RUNTIME)
11 | public @interface ActivityScope {
12 | }
--------------------------------------------------------------------------------
/hello-dagger1-simple/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.1.0'
9 | }
10 | }
11 |
12 | allprojects {
13 | repositories {
14 | jcenter()
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 |
19 | # Local configuration file (sdk path, etc)
20 | local.properties
21 |
22 | # Proguard folder generated by Eclipse
23 | proguard/
24 |
25 | # Log Files
26 | *.log
27 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/java/com/codeblast/hellodagger1/TimeServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | import java.util.Calendar;
4 | import java.util.GregorianCalendar;
5 |
6 | import javax.inject.Inject;
7 |
8 | public class TimeServiceImpl implements TimeService {
9 | public TimeServiceImpl() {
10 | }
11 |
12 | @Override
13 | public int currentHour() {
14 | return new GregorianCalendar().get(Calendar.HOUR_OF_DAY);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/res/menu/menu_hello.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/androidTest/java/com/codeblast/hellodagger1/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/hello-dagger2-simple/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.1.0'
9 | }
10 | }
11 |
12 | allprojects {
13 | repositories {
14 | jcenter()
15 | maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/java/com/codeblast/hellodagger2/TimeServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger2;
2 |
3 | import java.util.Calendar;
4 | import java.util.GregorianCalendar;
5 |
6 | import javax.inject.Inject;
7 |
8 | public class TimeServiceImpl implements TimeService {
9 | @Inject
10 | public TimeServiceImpl() {
11 | }
12 |
13 | @Override
14 | public int currentHour() {
15 | return new GregorianCalendar().get(Calendar.HOUR_OF_DAY);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
12 |
13 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/java/com/codeblast/hellodagger1/MyApplication.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | import android.app.Application;
4 |
5 | import dagger.ObjectGraph;
6 |
7 | public class MyApplication extends Application {
8 |
9 | private ObjectGraph objectGraph;
10 |
11 | @Override
12 | public void onCreate() {
13 | super.onCreate();
14 | objectGraph = ObjectGraph.create(new RootModule(this));
15 | }
16 |
17 | public ObjectGraph getObjectGraph() {
18 | return objectGraph;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/java/com/codeblast/hellodagger1/HelloPresenterImpl.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | import javax.inject.Inject;
4 |
5 | public class HelloPresenterImpl implements HelloPresenter {
6 | private final HelloView view;
7 | private final MessageSupplier messageSupplier;
8 |
9 | @Inject
10 | public HelloPresenterImpl(HelloView view, MessageSupplier messageSupplier) {
11 | this.view = view;
12 | this.messageSupplier = messageSupplier;
13 | }
14 |
15 | public void requestMessage() {
16 | view.onMessageUpdated(messageSupplier.getMessage());
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/java/com/codeblast/hellodagger2/HelloPresenterImpl.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger2;
2 |
3 | import javax.inject.Inject;
4 |
5 | public class HelloPresenterImpl implements HelloPresenter {
6 | private final HelloView view;
7 | private final MessageSupplier messageSupplier;
8 |
9 | @Inject
10 | public HelloPresenterImpl(HelloView view, MessageSupplier messageSupplier) {
11 | this.view = view;
12 | this.messageSupplier = messageSupplier;
13 | }
14 |
15 | public void requestMessage() {
16 | view.onMessageUpdated(messageSupplier.getMessage());
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/glombard/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/java/com/codeblast/hellodagger1/RootModule.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | import android.content.Context;
4 |
5 | import javax.inject.Singleton;
6 |
7 | import dagger.Module;
8 | import dagger.Provides;
9 |
10 | @Module(
11 | library = true,
12 | complete = false
13 | )
14 | public class RootModule {
15 | private final Context _context;
16 |
17 | public RootModule(Context context) {
18 | _context = context;
19 | }
20 |
21 | @Provides
22 | @Singleton
23 | public Context provideApplicationContext() {
24 | return _context;
25 | }
26 |
27 | @Provides
28 | @Singleton
29 | public TimeService provideTimeService() {
30 | return new TimeServiceImpl();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/glombard/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/java/com/codeblast/hellodagger1/HelloModule.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | import dagger.Module;
4 | import dagger.Provides;
5 |
6 | @Module(injects = {MainActivity.class}, addsTo = RootModule.class)
7 | public class HelloModule {
8 |
9 | private final MainActivity activity;
10 |
11 | public HelloModule(MainActivity activity) {
12 | this.activity = activity;
13 | }
14 |
15 | @Provides
16 | HelloView helloView() {
17 | return activity;
18 | }
19 |
20 | @Provides
21 | MessageSupplier messageSupplier(MessageSupplierImpl impl) {
22 | return impl;
23 | }
24 |
25 | @Provides
26 | HelloPresenter helloPresenter(HelloPresenterImpl impl) {
27 | return impl;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/java/com/codeblast/hellodagger1/MessageSupplierImpl.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | import javax.inject.Inject;
4 |
5 | public class MessageSupplierImpl implements MessageSupplier {
6 |
7 | private final TimeService timeService;
8 |
9 | @Inject
10 | public MessageSupplierImpl(TimeService timeService) {
11 | this.timeService = timeService;
12 | }
13 |
14 | @Override
15 | public String getMessage() {
16 | int hour = timeService.currentHour();
17 | String partOfDay;
18 | if (hour < 12)
19 | partOfDay = "morning";
20 | else if (hour >= 17)
21 | partOfDay = "evening";
22 | else
23 | partOfDay = "afternoon";
24 | return "Good " + partOfDay + ", Dagger 1.2!";
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/java/com/codeblast/hellodagger2/HelloModule.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger2;
2 |
3 | import dagger.Module;
4 | import dagger.Provides;
5 |
6 | @Module
7 | public class HelloModule {
8 | private final HelloView view;
9 |
10 | public HelloModule(HelloView view) {
11 | this.view = view;
12 | }
13 |
14 | @Provides
15 | HelloView helloView() {
16 | return this.view;
17 | }
18 |
19 | @Provides
20 | MessageSupplier messageSupplier(MessageSupplierImpl impl) {
21 | return impl;
22 | }
23 |
24 | @Provides
25 | TimeService timeService(TimeServiceImpl impl) {
26 | return impl;
27 | }
28 |
29 | @Provides
30 | HelloPresenter helloPresenter(HelloPresenterImpl impl) {
31 | return impl;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/java/com/codeblast/hellodagger2/MessageSupplierImpl.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger2;
2 |
3 | import javax.inject.Inject;
4 |
5 | public class MessageSupplierImpl implements MessageSupplier {
6 |
7 | private final TimeService timeService;
8 |
9 | @Inject
10 | public MessageSupplierImpl(TimeService timeService) {
11 | this.timeService = timeService;
12 | }
13 |
14 | @Override
15 | public String getMessage() {
16 | int hour = timeService.currentHour();
17 | String partOfDay;
18 | if (hour < 12)
19 | partOfDay = "morning";
20 | else if (hour >= 17)
21 | partOfDay = "evening";
22 | else
23 | partOfDay = "afternoon";
24 | return "Good " + partOfDay + ", Dagger 2.0!";
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/res/layout/activity_hello.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/hello-dagger1-simple.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/hello-dagger2-simple.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/hello-dagger2-simple/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/main/java/com/codeblast/hellodagger2/HelloActivity.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger2;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.ActionBarActivity;
5 | import android.widget.TextView;
6 |
7 | import javax.inject.Inject;
8 |
9 | public class HelloActivity extends ActionBarActivity implements HelloView {
10 |
11 | @Inject
12 | HelloPresenter presenter;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_hello);
18 |
19 | Dagger_HelloComponent.builder()
20 | .helloModule(new HelloModule(this))
21 | .build()
22 | .initialize(this);
23 | }
24 |
25 | @Override
26 | protected void onPostResume() {
27 | super.onPostResume();
28 | presenter.requestMessage();
29 | }
30 |
31 | @Override
32 | public void onMessageUpdated(final String message) {
33 | ((TextView) findViewById(R.id.message)).setText(message);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | applicationId "com.codeblast.hellodagger2"
9 | minSdkVersion 14
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:21.0.3'
25 | compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
26 | provided 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
27 | compile 'org.glassfish:javax.annotation:10.0-b28'
28 | androidTestCompile "org.mockito:mockito-core:1.10.19"
29 | androidTestCompile 'com.google.dexmaker:dexmaker:1.1'
30 | androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.1'
31 | }
32 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/main/java/com/codeblast/hellodagger1/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.widget.TextView;
6 |
7 | import javax.inject.Inject;
8 |
9 | import dagger.ObjectGraph;
10 |
11 | public class MainActivity extends Activity implements HelloView {
12 |
13 | @Inject
14 | HelloPresenter presenter;
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_main);
20 |
21 | ObjectGraph parentObjectGraph = ((MyApplication) getApplication()).getObjectGraph();
22 | ObjectGraph objectGraph = parentObjectGraph.plus(new HelloModule(this));
23 | objectGraph.inject(this);
24 | }
25 |
26 | @Override
27 | protected void onPostResume() {
28 | super.onPostResume();
29 | presenter.requestMessage();
30 | }
31 |
32 | @Override
33 | public void onMessageUpdated(String message) {
34 | ((TextView) findViewById(R.id.message)).setText(message);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/androidTest/java/com/codeblast/hellodagger2/MessageSupplierTest.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger2;
2 |
3 | import junit.framework.TestCase;
4 |
5 | import static org.mockito.Mockito.mock;
6 | import static org.mockito.Mockito.when;
7 |
8 | public class MessageSupplierTest extends TestCase {
9 | private final String MORNING = "Good morning, Dagger 2.0!";
10 | private final String AFTERNOON = "Good afternoon, Dagger 2.0!";
11 | private final String EVENING = "Good evening, Dagger 2.0!";
12 |
13 | public void testMidnightIsMorning() {
14 | runTest(0, MORNING);
15 | }
16 |
17 | public void testElevenAmIsMorning() {
18 | runTest(11, MORNING);
19 | }
20 |
21 | public void testTwelvePmIsAfternoon() {
22 | runTest(12, AFTERNOON);
23 | }
24 |
25 | public void testFourPmIsAfternoon() {
26 | runTest(16, AFTERNOON);
27 | }
28 |
29 | public void testFivePmIsEvening() {
30 | runTest(17, EVENING);
31 | }
32 |
33 | public void testElevenPmIsEvening() {
34 | runTest(23, EVENING);
35 | }
36 |
37 | private void runTest(int hour, String expectedMessage) {
38 |
39 | TimeService timeService = mock(TimeService.class);
40 | when(timeService.currentHour()).thenReturn(hour);
41 | MessageSupplier supplier = new MessageSupplierImpl(timeService);
42 | String result = supplier.getMessage();
43 | assertEquals(expectedMessage, result);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/test/java/com/codeblast/hellodagger1/MyTestRunner.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | import android.app.Activity;
4 |
5 | import org.junit.runners.model.InitializationError;
6 | import org.robolectric.AndroidManifest;
7 | import org.robolectric.RobolectricTestRunner;
8 | import org.robolectric.annotation.Config;
9 | import org.robolectric.res.Fs;
10 |
11 | import java.io.File;
12 |
13 | public class MyTestRunner extends RobolectricTestRunner {
14 | private static final int ROBOLECTRIC_SDK_VERSION = 18;
15 | private static final String ROBOLECTRIC_THEME = "@style/RoboAppTheme";
16 |
17 | public MyTestRunner(Class> testClass)
18 | throws InitializationError {
19 | super(testClass);
20 | }
21 |
22 | @Override
23 | protected AndroidManifest getAppManifest(Config config) {
24 | String path = "src/main";
25 | if (!new File(path).exists()) {
26 | path = "app/" + path;
27 | }
28 | final String manifestProperty = path + "/AndroidManifest.xml";
29 | final String resProperty = path + "/res";
30 | return new AndroidManifest(Fs.fileFromPath(manifestProperty), Fs.fileFromPath(resProperty)) {
31 | @Override
32 | public int getTargetSdkVersion() {
33 | return ROBOLECTRIC_SDK_VERSION;
34 | }
35 |
36 | @Override
37 | public String getThemeRef(Class extends Activity> activityClass) {
38 | return ROBOLECTRIC_THEME;
39 | }
40 | };
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/src/test/java/com/codeblast/hellodagger1/MainActivityTest.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger1;
2 |
3 | import android.widget.TextView;
4 |
5 | import org.junit.Test;
6 | import org.junit.runner.RunWith;
7 | import org.robolectric.Robolectric;
8 | import org.robolectric.util.ActivityController;
9 |
10 | import static org.junit.Assert.assertEquals;
11 | import static org.junit.Assert.fail;
12 | import static org.mockito.Mockito.mock;
13 | import static org.mockito.Mockito.verify;
14 |
15 | @RunWith(MyTestRunner.class)
16 | public class MainActivityTest {
17 |
18 | @Test
19 | public void testInitialDefaultMessage() {
20 | ActivityController controller = Robolectric.buildActivity(MainActivity.class)
21 | .create();
22 |
23 | MainActivity activity = controller.get();
24 | TextView text = (TextView) activity.findViewById(R.id.message);
25 | assertEquals("Dagger 1 test starting!", text.getText());
26 | }
27 |
28 | @Test
29 | public void testInitiallyNoCallToPresenterInOnCreate() {
30 | // TODO: can't do this yet, because it's too late to override presenter after onCreate...
31 | fail();
32 | }
33 |
34 | @Test
35 | public void testOnPostResumeRequestsMessageFromPresenter() {
36 | ActivityController controller = Robolectric.buildActivity(MainActivity.class)
37 | .create();
38 |
39 | MainActivity activity = controller.get();
40 |
41 | // Hack: override Presenter with a mock...
42 | activity.presenter = mock(HelloPresenter.class);
43 |
44 | TextView text = (TextView) activity.findViewById(R.id.message);
45 | controller.resume().visible();
46 |
47 | verify(activity.presenter).requestMessage();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | applicationId "com.codeblast.hellodagger1"
9 | minSdkVersion 14
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile 'com.android.support:appcompat-v7:21.0.3'
24 | compile 'com.squareup.dagger:dagger:1.2.2'
25 | provided 'com.squareup.dagger:dagger-compiler:1.2.2'
26 |
27 | testCompile 'org.mockito:mockito-core:1.10.19'
28 | testCompile 'junit:junit:4.12'
29 |
30 | // see: https://github.com/robolectric/robolectric/issues/1175
31 | testCompile('org.robolectric:robolectric:2.4') {
32 | exclude module: 'classworlds'
33 | exclude module: 'commons-logging'
34 | exclude module: 'httpclient'
35 | exclude module: 'maven-artifact'
36 | exclude module: 'maven-artifact-manager'
37 | exclude module: 'maven-error-diagnostics'
38 | exclude module: 'maven-model'
39 | exclude module: 'maven-project'
40 | exclude module: 'maven-settings'
41 | exclude module: 'plexus-container-default'
42 | exclude module: 'plexus-interpolation'
43 | exclude module: 'plexus-utils'
44 | exclude module: 'wagon-file'
45 | exclude module: 'wagon-http-lightweight'
46 | exclude module: 'wagon-provider-api'
47 | exclude group: 'com.android.support', module: 'support-v4'
48 | exclude group: 'com.android.support', module: 'appcompat-v7'
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/src/androidTest/java/com/codeblast/hellodagger2/HelloActivityTest.java:
--------------------------------------------------------------------------------
1 | package com.codeblast.hellodagger2;
2 |
3 | import android.test.ActivityUnitTestCase;
4 | import android.test.UiThreadTest;
5 | import android.view.ContextThemeWrapper;
6 | import android.widget.TextView;
7 |
8 | import javax.inject.Inject;
9 |
10 | import dagger.Module;
11 | import dagger.Provides;
12 |
13 | import static org.mockito.Mockito.mock;
14 | import static org.mockito.Mockito.verify;
15 |
16 | public class HelloActivityTest extends ActivityUnitTestCase {
17 | HelloActivity activity;
18 |
19 | @Inject
20 | HelloPresenter presenter;
21 |
22 | public HelloActivityTest() {
23 | super(HelloActivity.class);
24 | }
25 |
26 | @Override
27 | protected void setUp() throws Exception {
28 | super.setUp();
29 |
30 | // Setup Theme.AppCompat theme for ActionBarActivity:
31 | ContextThemeWrapper context = new ContextThemeWrapper(getInstrumentation().getTargetContext(), R.style.AppTheme);
32 | setActivityContext(context);
33 |
34 | setActivity(launchActivity("com.codeblast.hellodagger2", HelloActivity.class, null));
35 | activity = getActivity();
36 |
37 | // At this point, onCreate has run and Dagger has already injected
38 | // the activity's members. How do I insert my MockModule into
39 | // the object graph here to inject a mock presenter?
40 |
41 | presenter = mock(HelloPresenter.class); // HACK! Must let Dagger do this...
42 | activity.presenter = presenter;
43 | }
44 |
45 | @UiThreadTest
46 | public void testOnPostResumeRequestsMessageFromPresenter() throws Throwable {
47 | activity.onPostResume();
48 | verify(presenter).requestMessage();
49 | }
50 |
51 | @UiThreadTest
52 | public void testOnMessageUpdateSetsText() throws Throwable {
53 | activity.onMessageUpdated("Abc.");
54 | TextView textView = (TextView) activity.findViewById(R.id.message);
55 | assertEquals("Abc.", textView.getText());
56 | }
57 |
58 | @Module(
59 | addsTo = HelloModule.class,
60 | overrides = true,
61 | injects = HelloActivityTest.class)
62 | class MockModule {
63 | @Provides
64 | HelloPresenter presenter() {
65 | // TODO: set up presenter as needed...
66 | return mock(HelloPresenter.class);
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/hello-dagger1-simple/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/hello-dagger2-simple/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/hello-dagger1-simple/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------