├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── DaggerTest.iml
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── opticus
│ │ │ └── daggertest
│ │ │ ├── App.java
│ │ │ ├── BaseActivity.java
│ │ │ ├── BaseFragment.java
│ │ │ ├── FirstFragment.java
│ │ │ ├── MainActivity.java
│ │ │ ├── SecondActivity.java
│ │ │ ├── SecondFragment.java
│ │ │ ├── SelectActivity.java
│ │ │ ├── async
│ │ │ ├── AsyncComponent.java
│ │ │ ├── AsyncInjectActivity.java
│ │ │ └── AsyncModule.java
│ │ │ ├── di
│ │ │ ├── ActModule.java
│ │ │ ├── AppComponent.java
│ │ │ ├── AppModule.java
│ │ │ ├── BusModule.java
│ │ │ ├── DbModule.java
│ │ │ ├── FirstFrComponent.java
│ │ │ ├── HasComponent.java
│ │ │ ├── MainActComponent.java
│ │ │ ├── ManagerBModule.java
│ │ │ ├── SecondActComponent.java
│ │ │ ├── SecondActModule.java
│ │ │ ├── SecondFrComponent.java
│ │ │ └── scope
│ │ │ │ ├── PerActivity.java
│ │ │ │ ├── PerApplication.java
│ │ │ │ └── PerFragment.java
│ │ │ └── managers
│ │ │ ├── DbHelper.java
│ │ │ ├── HugeManager.java
│ │ │ ├── ManagerA.java
│ │ │ └── ManagerB.java
│ └── res
│ │ ├── layout
│ │ ├── activity_async_inject.xml
│ │ ├── activity_main.xml
│ │ ├── activity_main2.xml
│ │ ├── activity_second.xml
│ │ ├── activity_select.xml
│ │ ├── content_main.xml
│ │ ├── fragment_blank.xml
│ │ ├── fragment_main.xml
│ │ └── fragment_second.xml
│ │ ├── menu
│ │ └── menu_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-v21
│ │ └── styles.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── opticus
│ └── daggertest
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | DaggerTest
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
22 |
23 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/DaggerTest.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
38 |
39 |
40 |
209 |
210 |
211 |
222 |
223 |
224 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
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 |
117 |
118 |
119 |
288 |
289 |
290 |
301 |
302 |
303 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | mavenCentral()
4 | }
5 | dependencies {
6 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
7 | }
8 | }
9 |
10 | apply plugin: 'com.android.application'
11 | apply plugin: 'com.neenbedankt.android-apt'
12 |
13 | android {
14 | compileSdkVersion 23
15 | buildToolsVersion "23.0.2"
16 |
17 | defaultConfig {
18 | applicationId "com.opticus.daggertest"
19 | minSdkVersion 16
20 | targetSdkVersion 23
21 | versionCode 1
22 | versionName "1.0"
23 | }
24 | buildTypes {
25 | release {
26 | minifyEnabled false
27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
28 | }
29 | }
30 | packagingOptions {
31 | exclude 'META-INF/services/javax.annotation.processing.Processor'
32 | }
33 | lintOptions {
34 | abortOnError false
35 | }
36 | }
37 |
38 | dependencies {
39 | compile 'com.android.support:appcompat-v7:23.1.1'
40 | compile 'com.android.support:design:23.1.1'
41 | compile 'com.google.dagger:dagger:2.0.1'
42 | compile 'com.google.dagger:dagger-producers:2.0-beta'
43 | apt 'com.google.dagger:dagger-compiler:2.0.1'
44 | compile 'com.squareup:otto:1.3.6'
45 | provided 'org.glassfish:javax.annotation:10.0-b28'
46 | compile 'io.reactivex:rxjava:1.0.10'
47 | }
48 |
--------------------------------------------------------------------------------
/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 /home/opticus/Android/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 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/App.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest;
2 |
3 | import android.app.Application;
4 | import android.util.Log;
5 |
6 | import com.opticus.daggertest.di.AppComponent;
7 | import com.opticus.daggertest.di.AppModule;
8 | import com.opticus.daggertest.di.DaggerAppComponent;
9 | import com.opticus.daggertest.di.HasComponent;
10 | import com.opticus.daggertest.managers.DbHelper;
11 |
12 | import javax.inject.Inject;
13 |
14 | public class App extends Application implements HasComponent {
15 | @Inject
16 | DbHelper dbHelper;
17 | private AppComponent component;
18 |
19 | @Override
20 | public void onCreate() {
21 | super.onCreate();
22 |
23 | this.component = createComponent();
24 | component.inject(this);
25 | Log.i("GTAG", "app db: " + dbHelper.hashCode());
26 | }
27 |
28 | @Override
29 | public AppComponent getComponent() {
30 | return component;
31 | }
32 |
33 | public AppComponent createComponent() {
34 | return DaggerAppComponent.builder()
35 | .appModule(new AppModule(this))
36 | .build();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | import com.opticus.daggertest.di.AppComponent;
7 | import com.squareup.otto.Bus;
8 |
9 | import javax.inject.Inject;
10 |
11 | public abstract class BaseActivity extends AppCompatActivity {
12 |
13 | @Inject
14 | protected Bus bus;
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | initDiComponent();
19 | super.onCreate(savedInstanceState);
20 | }
21 |
22 | abstract protected void initDiComponent();
23 |
24 | protected AppComponent getAppComponent() {
25 | return ((App) getApplication()).getComponent();
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v4.app.Fragment;
7 |
8 | import com.opticus.daggertest.di.HasComponent;
9 | import com.squareup.otto.Bus;
10 |
11 | import javax.inject.Inject;
12 |
13 | public abstract class BaseFragment extends Fragment {
14 | @Inject
15 | Bus bus;
16 |
17 | @Override
18 | public void onActivityCreated(@Nullable Bundle savedInstanceState) {
19 | super.onActivityCreated(savedInstanceState);
20 | initDiComponent();
21 | }
22 |
23 | abstract protected void initDiComponent();
24 |
25 | @Override
26 | public void onResume() {
27 | super.onResume();
28 | bus.register(this);
29 | }
30 |
31 | @Override
32 | public void onPause() {
33 | super.onPause();
34 | bus.unregister(this);
35 | }
36 |
37 | public T getActComponent(Class clazz) {
38 | Activity activity = getActivity();
39 | HasComponent has = (HasComponent) activity;
40 | return has.getComponent();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/FirstFragment.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import com.opticus.daggertest.di.DaggerFirstFrComponent;
10 | import com.opticus.daggertest.di.FirstFrComponent;
11 | import com.opticus.daggertest.managers.ManagerA;
12 |
13 | import javax.inject.Inject;
14 | import javax.inject.Provider;
15 |
16 | public class FirstFragment extends BaseFragment {
17 |
18 | @Inject
19 | Provider managerA;
20 |
21 | public FirstFragment() {
22 | }
23 |
24 | @Override
25 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
26 | Bundle savedInstanceState) {
27 | return inflater.inflate(R.layout.fragment_main, container, false);
28 | }
29 |
30 | @Override
31 | public void onActivityCreated(Bundle savedInstanceState) {
32 | super.onActivityCreated(savedInstanceState);
33 | Log.i("GTAG", "1 fr bus: " + bus.hashCode());
34 | Log.i("GTAG", "1 fr managerA: " + managerA.get().hashCode());
35 | Log.i("GTAG", "1 fr managerA: " + managerA.get().hashCode());
36 | Log.i("GTAG", "1 fr managerA: " + managerA.get().hashCode());
37 | }
38 |
39 | @Override
40 | protected void initDiComponent() {
41 | FirstFrComponent.HasFirstFrDepends actComponent = getActComponent(FirstFrComponent.HasFirstFrDepends.class);
42 | DaggerFirstFrComponent.builder()
43 | .hasFirstFrDepends(actComponent)
44 | .build()
45 | .inject(this);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 |
6 | import com.opticus.daggertest.di.ActModule;
7 | import com.opticus.daggertest.di.DaggerMainActComponent;
8 | import com.opticus.daggertest.di.HasComponent;
9 | import com.opticus.daggertest.di.MainActComponent;
10 | import com.opticus.daggertest.managers.ManagerA;
11 | import com.squareup.otto.Bus;
12 |
13 | import javax.inject.Inject;
14 |
15 | import dagger.Lazy;
16 |
17 | public class MainActivity extends BaseActivity implements HasComponent {
18 |
19 | MainActComponent actComponent;
20 |
21 | @Inject
22 | Lazy managerA;
23 |
24 | @Override
25 | public void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.activity_main);
28 | Log.i("GTAG", "mAct bus: " + bus.hashCode());
29 | Log.i("GTAG", "mAct managerA: " + managerA.get().hashCode());
30 | Log.i("GTAG", "mAct managerA: " + managerA.get().hashCode());
31 | Log.i("GTAG", "mAct managerA: " + managerA.get().hashCode());
32 | }
33 |
34 | @Override
35 | protected void initDiComponent() {
36 | actComponent = DaggerMainActComponent
37 | .builder()
38 | .appComponent(getAppComponent())
39 | .actModule(new ActModule(this))
40 | .build();
41 | actComponent.inject(this);
42 | }
43 |
44 | @Override
45 | public MainActComponent getComponent() {
46 | return actComponent;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/SecondActivity.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 |
6 | import com.opticus.daggertest.di.DaggerSecondActComponent;
7 | import com.opticus.daggertest.di.HasComponent;
8 | import com.opticus.daggertest.di.SecondActComponent;
9 | import com.opticus.daggertest.di.SecondActModule;
10 | import com.squareup.otto.Bus;
11 |
12 | import javax.inject.Inject;
13 |
14 | public class SecondActivity extends BaseActivity implements HasComponent {
15 |
16 | @Inject
17 | Bus bus;
18 | private SecondActComponent component;
19 |
20 | @Override
21 | public void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_second);
24 | Log.i("GTAG", "sAct bus: " + bus.hashCode());
25 | }
26 |
27 | @Override
28 | protected void initDiComponent() {
29 | component = DaggerSecondActComponent.builder()
30 | .appComponent(getAppComponent())
31 | .secondActModule(new SecondActModule(this))
32 | .build();
33 | component.inject(this);
34 | }
35 |
36 | @Override
37 | public SecondActComponent getComponent() {
38 | return component;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/SecondFragment.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import com.opticus.daggertest.di.SecondFrComponent;
10 | import com.opticus.daggertest.managers.DbHelper;
11 | import com.opticus.daggertest.managers.ManagerB;
12 |
13 | import javax.inject.Inject;
14 |
15 | public class SecondFragment extends BaseFragment {
16 |
17 | @Inject
18 | DbHelper dbHelper;
19 | @Inject
20 | ManagerB managerB;
21 |
22 | public SecondFragment() {
23 | // Required empty public constructor
24 | }
25 |
26 |
27 | @Override
28 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
29 | Bundle savedInstanceState) {
30 | return inflater.inflate(R.layout.fragment_second, container, false);
31 | }
32 |
33 | @Override
34 | public void onActivityCreated(Bundle savedInstanceState) {
35 | super.onActivityCreated(savedInstanceState);
36 | Log.i("GTAG", "2 fr db: " + dbHelper.hashCode());
37 | Log.i("GTAG", "2 fr bus: " + bus.hashCode());
38 | Log.i("GTAG", "2 fr managerB: " + managerB.hashCode());
39 | }
40 |
41 | @Override
42 | protected void initDiComponent() {
43 | SecondFrComponent.PlusComponent actComponent = getActComponent(SecondFrComponent.PlusComponent.class);
44 | SecondFrComponent component = actComponent.plusSecondFrComponent();
45 | component.inject(this);
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/SelectActivity.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 |
8 | import com.opticus.daggertest.async.AsyncInjectActivity;
9 |
10 | public class SelectActivity extends AppCompatActivity {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_select);
16 | }
17 |
18 | public void click1(View view) {
19 | startActivity(new Intent(this, MainActivity.class));
20 | }
21 |
22 | public void click2(View view) {
23 | startActivity(new Intent(this, SecondActivity.class));
24 | }
25 |
26 | public void click3(View view) {
27 | startActivity(new Intent(this, AsyncInjectActivity.class));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/async/AsyncComponent.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.async;
2 |
3 | import com.google.common.util.concurrent.ListenableFuture;
4 | import com.opticus.daggertest.managers.HugeManager;
5 |
6 | import dagger.producers.ProductionComponent;
7 |
8 | @ProductionComponent(modules = AsyncModule.class)
9 | public interface AsyncComponent {
10 | ListenableFuture hugeManager();
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/async/AsyncInjectActivity.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.async;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | import com.google.common.util.concurrent.ListenableFuture;
7 | import com.opticus.daggertest.R;
8 | import com.opticus.daggertest.managers.HugeManager;
9 |
10 | import java.util.concurrent.ExecutionException;
11 | import java.util.concurrent.Executors;
12 |
13 | public class AsyncInjectActivity extends AppCompatActivity {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | initDiComponent();
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_async_inject);
20 | }
21 |
22 | protected void initDiComponent() {
23 | AsyncComponent component = DaggerAsyncComponent
24 | .builder()
25 | .asyncModule(new AsyncModule())
26 | .executor(Executors.newSingleThreadExecutor())
27 | .build();
28 | ListenableFuture future = component.hugeManager();
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/async/AsyncModule.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.async;
2 |
3 | import com.google.common.util.concurrent.Futures;
4 | import com.google.common.util.concurrent.ListenableFuture;
5 | import com.opticus.daggertest.managers.HugeManager;
6 |
7 | import dagger.producers.ProducerModule;
8 | import dagger.producers.Produces;
9 |
10 | @ProducerModule
11 | public class AsyncModule {
12 | @Produces
13 | ListenableFuture produceHugeManager() {
14 | return Futures.immediateFuture(new HugeManager());
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/ActModule.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di;
2 |
3 | import com.opticus.daggertest.BaseActivity;
4 |
5 | import dagger.Module;
6 |
7 | @Module()
8 | public class ActModule {
9 |
10 | private BaseActivity activity;
11 |
12 | public ActModule(BaseActivity activity) {
13 | this.activity = activity;
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/AppComponent.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di;
2 |
3 | import android.content.Context;
4 |
5 | import com.opticus.daggertest.App;
6 | import com.opticus.daggertest.di.scope.PerApplication;
7 | import com.opticus.daggertest.managers.DbHelper;
8 |
9 | import dagger.Component;
10 |
11 | @PerApplication
12 | @Component(modules = {AppModule.class})
13 | public interface AppComponent {
14 | void inject(App app);
15 |
16 | Context context();
17 |
18 | DbHelper dbHelper();
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/AppModule.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di;
2 |
3 | import android.content.Context;
4 |
5 | import com.opticus.daggertest.App;
6 | import com.opticus.daggertest.di.scope.PerApplication;
7 |
8 | import dagger.Module;
9 | import dagger.Provides;
10 |
11 | @Module(includes = DbModule.class)
12 | public class AppModule {
13 | protected final App application;
14 |
15 | public AppModule(App application) {
16 | this.application = application;
17 | }
18 |
19 | @PerApplication
20 | @Provides
21 | public Context provideContext() {
22 | return application.getApplicationContext();
23 | }
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/BusModule.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di;
2 |
3 | import com.opticus.daggertest.di.scope.PerActivity;
4 | import com.squareup.otto.Bus;
5 |
6 | import dagger.Module;
7 | import dagger.Provides;
8 |
9 | @Module
10 | public class BusModule {
11 | @Provides
12 | @PerActivity
13 | public Bus provideBus() {
14 | return new Bus("default");
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/DbModule.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di;
2 |
3 | import android.content.Context;
4 |
5 | import com.opticus.daggertest.di.scope.PerApplication;
6 | import com.opticus.daggertest.managers.DbHelper;
7 |
8 | import dagger.Module;
9 | import dagger.Provides;
10 |
11 | @Module
12 | public class DbModule {
13 | @PerApplication
14 | @Provides
15 | DbHelper dbHelper(Context context) {
16 | return new DbHelper(context);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/FirstFrComponent.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di;
2 |
3 | import android.content.Context;
4 |
5 | import com.opticus.daggertest.FirstFragment;
6 | import com.opticus.daggertest.di.scope.PerFragment;
7 | import com.opticus.daggertest.managers.ManagerA;
8 | import com.squareup.otto.Bus;
9 |
10 | import dagger.Component;
11 |
12 | @PerFragment
13 | @Component(dependencies = {FirstFrComponent.HasFirstFrDepends.class})
14 | public interface FirstFrComponent {
15 | void inject(FirstFragment fragment);
16 |
17 | interface HasFirstFrDepends {
18 | Bus bus();
19 |
20 | Context context();
21 |
22 | ManagerA managerA();
23 |
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/HasComponent.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di;
2 |
3 | public interface HasComponent {
4 |
5 | T getComponent();
6 | }
7 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/MainActComponent.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di;
2 |
3 | import com.opticus.daggertest.MainActivity;
4 | import com.opticus.daggertest.di.scope.PerActivity;
5 |
6 | import dagger.Component;
7 |
8 | @PerActivity
9 | @Component(modules = {ActModule.class, BusModule.class}, dependencies = AppComponent.class)
10 | public interface MainActComponent extends
11 | SecondFrComponent.PlusComponent, // SubComponent way
12 | FirstFrComponent.HasFirstFrDepends {//Depends component way
13 |
14 | void inject(MainActivity activity);
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/ManagerBModule.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di;
2 |
3 | import com.opticus.daggertest.di.scope.PerFragment;
4 | import com.opticus.daggertest.managers.ManagerB;
5 |
6 | import dagger.Module;
7 | import dagger.Provides;
8 |
9 | @Module
10 | public class ManagerBModule {
11 | @PerFragment
12 | @Provides
13 | ManagerB provideManagerB() {
14 | return new ManagerB();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/SecondActComponent.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di;
2 |
3 | import com.opticus.daggertest.SecondActivity;
4 | import com.opticus.daggertest.di.scope.PerActivity;
5 |
6 | import dagger.Component;
7 |
8 | @PerActivity
9 | @Component(dependencies = {AppComponent.class}, modules = {SecondActModule.class})
10 | public interface SecondActComponent extends SecondFrComponent.PlusComponent {
11 | void inject(SecondActivity activity);
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/SecondActModule.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di;
2 |
3 | import com.opticus.daggertest.SecondActivity;
4 |
5 | import dagger.Module;
6 |
7 | @Module(includes = BusModule.class)
8 | public class SecondActModule {
9 | private SecondActivity activity;
10 |
11 | public SecondActModule(SecondActivity activity) {
12 | this.activity = activity;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/SecondFrComponent.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di;
2 |
3 | import com.opticus.daggertest.SecondFragment;
4 | import com.opticus.daggertest.di.scope.PerFragment;
5 |
6 | import dagger.Subcomponent;
7 |
8 |
9 | @PerFragment
10 | @Subcomponent(modules = {ManagerBModule.class})
11 | public interface SecondFrComponent {
12 | void inject(SecondFragment fragment);
13 |
14 | interface PlusComponent {
15 | SecondFrComponent plusSecondFrComponent();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/scope/PerActivity.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di.scope;
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 PerActivity {
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/scope/PerApplication.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di.scope;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.RetentionPolicy;
5 |
6 | import javax.inject.Scope;
7 |
8 | @Scope
9 | @Retention(RetentionPolicy.RUNTIME)
10 | public @interface PerApplication {
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/di/scope/PerFragment.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.di.scope;
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 PerFragment {
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/managers/DbHelper.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.managers;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * Created by opticus on 13.10.15.
7 | */
8 | public class DbHelper {
9 | public Context context;
10 |
11 | public DbHelper(Context context) {
12 | this.context = context;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/managers/HugeManager.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.managers;
2 |
3 | import android.util.Log;
4 |
5 | import java.util.concurrent.TimeUnit;
6 |
7 | public class HugeManager {
8 | public HugeManager() {
9 | Log.i("GTAG", "init huge on: " + Thread.currentThread().getName());
10 | try {
11 | TimeUnit.SECONDS.sleep(3);
12 | } catch (InterruptedException e) {
13 | e.printStackTrace();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/managers/ManagerA.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.managers;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 |
6 | import com.opticus.daggertest.di.scope.PerActivity;
7 |
8 | import javax.inject.Inject;
9 |
10 |
11 | public class ManagerA {
12 | public Context context;
13 |
14 | @Inject
15 | public ManagerA(Context context) {
16 | this.context = context;
17 | }
18 |
19 | @Inject
20 | void init(Context context) {
21 | Log.i("GTAG", "method injection");
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/opticus/daggertest/managers/ManagerB.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest.managers;
2 |
3 | import android.content.Context;
4 |
5 | import javax.inject.Inject;
6 |
7 | public class ManagerB {
8 |
9 | @Inject
10 | void init(Context context) {
11 |
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_async_inject.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
16 |
17 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main2.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_select.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
18 |
19 |
24 |
25 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_blank.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_second.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/georgeci/DaggerTest/5359678ca622bc45a60cf8dfcb69df9d1c13ced2/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/georgeci/DaggerTest/5359678ca622bc45a60cf8dfcb69df9d1c13ced2/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/georgeci/DaggerTest/5359678ca622bc45a60cf8dfcb69df9d1c13ced2/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/georgeci/DaggerTest/5359678ca622bc45a60cf8dfcb69df9d1c13ced2/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/georgeci/DaggerTest/5359678ca622bc45a60cf8dfcb69df9d1c13ced2/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | DaggerTest
3 | Settings
4 |
5 |
6 | Hello blank fragment
7 | Async Producer
8 | Second Activity + 1 Fragment
9 | FirstActivity + 2 Fragments
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/test/java/com/opticus/daggertest/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.opticus.daggertest;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/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.3.1'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/georgeci/DaggerTest/5359678ca622bc45a60cf8dfcb69df9d1c13ced2/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Oct 09 15:32:11 MSK 2015
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.9-all.zip
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------