-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using dependency injection with dagger
- Loading branch information
Showing
15 changed files
with
90 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<factorypath> | ||
<factorypathentry kind="WKSPJAR" id="/android-stopwatch/libs/dagger-1.2.0.jar" enabled="true" runInBatchMode="false"/> | ||
<factorypathentry kind="WKSPJAR" id="/android-stopwatch/libs/javax.inject-1.jar" enabled="true" runInBatchMode="false"/> | ||
<factorypathentry kind="WKSPJAR" id="/android-stopwatch/libs/dagger-compiler-1.2.0.jar" enabled="true" runInBatchMode="false"/> | ||
<factorypathentry kind="WKSPJAR" id="/android-stopwatch/libs/javawriter-2.4.0.jar" enabled="true" runInBatchMode="false"/> | ||
</factorypath> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,5 @@ proguard/ | |
*.ipr | ||
*.iws | ||
.idea/ | ||
/apt_generated/ | ||
/lint.xml |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.apt.aptEnabled=true | ||
org.eclipse.jdt.apt.genSrcDir=apt_generated | ||
org.eclipse.jdt.apt.reconcileEnabled=true |
This file contains 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.alsoftlab.stopwatch; | ||
|
||
import dagger.ObjectGraph; | ||
|
||
/** | ||
* Initialized dependency graph. | ||
*/ | ||
public class Injector | ||
{ | ||
public static ObjectGraph graph; | ||
public static void init(Object... modules) | ||
{ | ||
graph = ObjectGraph.create(modules); | ||
} | ||
|
||
public static void inject(Object target) | ||
{ | ||
graph.inject(target); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* | ||
*/ | ||
package org.alsoftlab.stopwatch; | ||
|
||
import android.app.Application; | ||
import android.util.Log; | ||
|
||
/** | ||
* @author al | ||
* | ||
*/ | ||
public class TimerApp extends Application { | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
|
||
Log.d("TimerApp", "onCreate"); | ||
|
||
Injector.init(new TimerLogicModule()); | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.alsoftlab.stopwatch; | ||
|
||
import dagger.*; | ||
|
||
@Module(injects = TimerActivity.class) | ||
public class TimerLogicModule { | ||
@Provides | ||
TimerLogic provideTimerLogic() { | ||
return new TimerLogic(); | ||
} | ||
} |