diff --git a/.gitignore b/.gitignore
index 72300e2..c2ba938 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,4 +32,5 @@ build/
**/.idea/caches
# layout inspector view captures
-captures
\ No newline at end of file
+captures
+.idea/
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
deleted file mode 100644
index 8c95146..0000000
--- a/.idea/codeStyles/Project.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
deleted file mode 100644
index 79ee123..0000000
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 06e7a44..2ed1050 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,69 +1,69 @@
buildscript {
- ext.kotlinVersion = '1.2.31'
- repositories {
- google()
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:3.1.0'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
- }
+ ext.kotlinVersion = '1.2.51'
+ repositories {
+ google()
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.1.0'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
+ }
}
allprojects {
- repositories {
- google()
- jcenter()
- }
+ repositories {
+ google()
+ jcenter()
+ }
}
subprojects { project ->
- group = GROUP
- version = VERSION_NAME
+ group = GROUP
+ version = VERSION_NAME
- apply plugin: 'checkstyle'
+ apply plugin: 'checkstyle'
- task checkstyle(type: Checkstyle) {
- configFile rootProject.file('checkstyle.xml')
- source 'src/main/java'
- ignoreFailures false
- showViolations true
- include '**/*.java'
+ task checkstyle(type: Checkstyle) {
+ configFile rootProject.file('checkstyle.xml')
+ source 'src/main/java'
+ ignoreFailures false
+ showViolations true
+ include '**/*.java'
- classpath = files()
- }
+ classpath = files()
+ }
- afterEvaluate {
- if (project.tasks.findByName('check')) {
- check.dependsOn('checkstyle')
+ afterEvaluate {
+ if (project.tasks.findByName('check')) {
+ check.dependsOn('checkstyle')
+ }
}
- }
}
task clean(type: Delete) {
- delete rootProject.buildDir
+ delete rootProject.buildDir
}
ext {
- minSdkVersion = 15
- targetSdkVersion = 27
- compileSdkVersion = 27
- buildToolsVersion = '27.0.3'
- sourceCompatibilityVersion = JavaVersion.VERSION_1_7
- targetCompatibilityVersion = JavaVersion.VERSION_1_7
+ minSdkVersion = 15
+ targetSdkVersion = 27
+ compileSdkVersion = 27
+ buildToolsVersion = '27.0.3'
+ sourceCompatibilityVersion = JavaVersion.VERSION_1_7
+ targetCompatibilityVersion = JavaVersion.VERSION_1_7
}
ext.deps = [
- gson : 'com.google.code.gson:gson:2.8.2',
- conceal : 'com.facebook.conceal:conceal:1.1.3@aar',
+ gson : 'com.google.code.gson:gson:2.8.2',
+ conceal : 'com.facebook.conceal:conceal:1.1.3@aar',
- // Test dependencies
- junit : 'junit:junit:4.12',
- truth : 'com.google.truth:truth:0.28',
- robolectric : 'org.robolectric:robolectric:3.3',
- mockito : 'org.mockito:mockito-core:2.8.9',
- espressoRunner: 'com.android.support.test:runner:0.5',
- espressoRules : 'com.android.support.test:rules:0.5',
- kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
+ // Test dependencies
+ junit : 'junit:junit:4.12',
+ truth : 'com.google.truth:truth:0.28',
+ robolectric : 'org.robolectric:robolectric:3.3',
+ mockito : 'org.mockito:mockito-core:2.8.9',
+ espressoRunner: 'com.android.support.test:runner:0.5',
+ espressoRules : 'com.android.support.test:rules:0.5',
+ kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
]
diff --git a/dagger-sample/build.gradle b/dagger-sample/build.gradle
new file mode 100644
index 0000000..4afae25
--- /dev/null
+++ b/dagger-sample/build.gradle
@@ -0,0 +1,41 @@
+apply plugin: 'com.android.application'
+apply plugin: 'kotlin-android'
+apply plugin: 'kotlin-kapt'
+
+android {
+ compileSdkVersion 27
+
+ defaultConfig {
+ applicationId "com.orhanobut.hawk.dagger.sample"
+ minSdkVersion 17
+ targetSdkVersion 27
+ versionCode 1
+ versionName "1.0"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+}
+
+dependencies {
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
+ implementation 'com.android.support:appcompat-v7:27.1.1'
+ implementation 'com.google.dagger:dagger:2.16'
+ implementation('com.google.dagger:dagger-android:2.16') {
+ exclude group: "com.android.support"
+ }
+ implementation('com.google.dagger:dagger-android-support:2.16') {
+ exclude group: "com.android.support"
+ }
+ kapt "com.google.dagger:dagger-compiler:2.16"
+ kapt("com.google.dagger:dagger-android-processor:2.16") {
+ exclude group: "com.android.support"
+ }
+ implementation project(':hawk')
+ implementation project(':hawk-dagger')
+}
diff --git a/dagger-sample/proguard-rules.pro b/dagger-sample/proguard-rules.pro
new file mode 100644
index 0000000..f1b4245
--- /dev/null
+++ b/dagger-sample/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/dagger-sample/src/main/AndroidManifest.xml b/dagger-sample/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..ad955ed
--- /dev/null
+++ b/dagger-sample/src/main/AndroidManifest.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/MainActivity.kt b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/MainActivity.kt
new file mode 100644
index 0000000..ee3d42c
--- /dev/null
+++ b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/MainActivity.kt
@@ -0,0 +1,40 @@
+package com.orhanobut.hawk.dagger.sample
+
+import android.os.Bundle
+import android.support.annotation.VisibleForTesting
+import android.support.v4.app.Fragment
+import android.support.v7.app.AppCompatActivity
+import com.orhanobut.hawk.dagger.Hawker
+import dagger.android.DispatchingAndroidInjector
+import dagger.android.support.HasSupportFragmentInjector
+import javax.inject.Inject
+
+@VisibleForTesting
+class MainActivity : AppCompatActivity(), HasSupportFragmentInjector {
+
+ @Inject
+ lateinit var hawker: Hawker
+
+ @Inject
+ lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector
+
+ override fun supportFragmentInjector() = dispatchingAndroidInjector
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+
+ save()
+ load()
+ }
+
+ private fun save() {
+ hawker.put("name", "Hawker")
+ hawker.put("description", "Hawk with Dagger 2 support")
+ }
+
+ private fun load() {
+ val name: String? = hawker.get("name")
+ val description: String? = hawker.get("description")
+ }
+}
diff --git a/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/MainApplication.kt b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/MainApplication.kt
new file mode 100644
index 0000000..6c88888
--- /dev/null
+++ b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/MainApplication.kt
@@ -0,0 +1,23 @@
+package com.orhanobut.hawk.dagger.sample
+
+import android.app.Activity
+import android.app.Application
+import com.orhanobut.hawk.dagger.sample.di.AppInjector
+import dagger.android.AndroidInjector
+import dagger.android.DispatchingAndroidInjector
+import dagger.android.HasActivityInjector
+import javax.inject.Inject
+
+class MainApplication : Application(), HasActivityInjector {
+ @Inject
+ lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector
+
+ override fun activityInjector(): AndroidInjector {
+ return dispatchingAndroidInjector
+ }
+
+ override fun onCreate() {
+ super.onCreate()
+ AppInjector.init(this)
+ }
+}
\ No newline at end of file
diff --git a/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/ActivityModule.kt b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/ActivityModule.kt
new file mode 100644
index 0000000..5194529
--- /dev/null
+++ b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/ActivityModule.kt
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.orhanobut.hawk.dagger.sample.di
+
+import com.orhanobut.hawk.dagger.sample.MainActivity
+import dagger.Module
+import dagger.android.ContributesAndroidInjector
+
+@Suppress("unused")
+@Module
+abstract class ActivityModule {
+ @ContributesAndroidInjector()
+ abstract fun contributeMainActivity(): MainActivity
+}
diff --git a/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/AppComponent.kt b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/AppComponent.kt
new file mode 100644
index 0000000..ee20b86
--- /dev/null
+++ b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/AppComponent.kt
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.orhanobut.hawk.dagger.sample.di
+
+import android.app.Application
+import com.orhanobut.hawk.dagger.sample.MainApplication
+import com.orhanobut.hawk.dagger.sample.di.ActivityModule
+import dagger.BindsInstance
+import dagger.Component
+import dagger.android.support.AndroidSupportInjectionModule
+import javax.inject.Singleton
+
+@Singleton
+@Component(
+ modules = [
+ AndroidSupportInjectionModule::class,
+ AppModule::class,
+ ActivityModule::class
+ ])
+interface AppComponent {
+ @Component.Builder
+ interface Builder {
+ @BindsInstance
+ fun application(application: Application): Builder
+
+ fun build(): AppComponent
+ }
+
+ fun inject(application: MainApplication)
+}
diff --git a/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/AppInjector.kt b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/AppInjector.kt
new file mode 100644
index 0000000..df4cfa9
--- /dev/null
+++ b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/AppInjector.kt
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.orhanobut.hawk.dagger.sample.di
+
+import android.app.Activity
+import android.app.Application
+import android.os.Bundle
+import android.support.v4.app.Fragment
+import android.support.v4.app.FragmentActivity
+import android.support.v4.app.FragmentManager
+import com.orhanobut.hawk.dagger.sample.MainApplication
+import dagger.android.AndroidInjection
+import dagger.android.support.AndroidSupportInjection
+import dagger.android.support.HasSupportFragmentInjector
+
+/**
+ * Helper class to automatically inject fragments if they implement [Injectable].
+ */
+object AppInjector {
+ fun init(app: MainApplication) {
+ DaggerAppComponent.builder()
+ .application(app)
+ .build().inject(app)
+ app.registerActivityLifecycleCallbacks(object : Application.ActivityLifecycleCallbacks {
+ override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
+ handleActivity(activity)
+ }
+
+ override fun onActivityStarted(activity: Activity) {
+
+ }
+
+ override fun onActivityResumed(activity: Activity) {
+
+ }
+
+ override fun onActivityPaused(activity: Activity) {
+
+ }
+
+ override fun onActivityStopped(activity: Activity) {
+
+ }
+
+ override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle?) {
+
+ }
+
+ override fun onActivityDestroyed(activity: Activity) {
+
+ }
+ })
+ }
+
+ private fun handleActivity(activity: Activity) {
+ if (activity is HasSupportFragmentInjector) {
+ AndroidInjection.inject(activity)
+ }
+ if (activity is FragmentActivity) {
+ activity.supportFragmentManager
+ .registerFragmentLifecycleCallbacks(
+ object : FragmentManager.FragmentLifecycleCallbacks() {
+ override fun onFragmentCreated(
+ fm: FragmentManager,
+ f: Fragment,
+ savedInstanceState: Bundle?
+ ) {
+ if (f is Injectable) {
+ AndroidSupportInjection.inject(f)
+ }
+ }
+ }, true
+ )
+ }
+ }
+}
diff --git a/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/AppModule.kt b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/AppModule.kt
new file mode 100644
index 0000000..25cd61f
--- /dev/null
+++ b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/AppModule.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@file:Suppress("FoldInitializerAndIfToElvis")
+
+package com.orhanobut.hawk.dagger.sample.di
+
+import android.annotation.SuppressLint
+import android.app.Application
+import com.orhanobut.hawk.dagger.Hawker
+import dagger.Module
+import dagger.Provides
+import javax.inject.Singleton
+
+@Module()
+class AppModule {
+ @Singleton
+ @Provides
+ fun provideHawk(app: Application): Hawker = Hawker(app.baseContext)
+}
diff --git a/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/Injectable.kt b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/Injectable.kt
new file mode 100644
index 0000000..6405ec7
--- /dev/null
+++ b/dagger-sample/src/main/kotlin/com/orhanobut/hawk/dagger/sample/di/Injectable.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.orhanobut.hawk.dagger.sample.di
+
+/**
+ * Marks an activity / fragment injectable.
+ */
+interface Injectable
diff --git a/dagger-sample/src/main/res/drawable-v24/ic_launcher_foreground.xml b/dagger-sample/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644
index 0000000..1f6bb29
--- /dev/null
+++ b/dagger-sample/src/main/res/drawable-v24/ic_launcher_foreground.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dagger-sample/src/main/res/drawable/ic_launcher_background.xml b/dagger-sample/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 0000000..0d025f9
--- /dev/null
+++ b/dagger-sample/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dagger-sample/src/main/res/layout/activity_main.xml b/dagger-sample/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..9cb42f5
--- /dev/null
+++ b/dagger-sample/src/main/res/layout/activity_main.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/dagger-sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/dagger-sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/dagger-sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/dagger-sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/dagger-sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/dagger-sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/dagger-sample/src/main/res/mipmap-hdpi/ic_launcher.png b/dagger-sample/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..898f3ed
Binary files /dev/null and b/dagger-sample/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/dagger-sample/src/main/res/mipmap-hdpi/ic_launcher_round.png b/dagger-sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 0000000..dffca36
Binary files /dev/null and b/dagger-sample/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/dagger-sample/src/main/res/mipmap-mdpi/ic_launcher.png b/dagger-sample/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..64ba76f
Binary files /dev/null and b/dagger-sample/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/dagger-sample/src/main/res/mipmap-mdpi/ic_launcher_round.png b/dagger-sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 0000000..dae5e08
Binary files /dev/null and b/dagger-sample/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/dagger-sample/src/main/res/mipmap-xhdpi/ic_launcher.png b/dagger-sample/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..e5ed465
Binary files /dev/null and b/dagger-sample/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/dagger-sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/dagger-sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..14ed0af
Binary files /dev/null and b/dagger-sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/dagger-sample/src/main/res/mipmap-xxhdpi/ic_launcher.png b/dagger-sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..b0907ca
Binary files /dev/null and b/dagger-sample/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/dagger-sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/dagger-sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..d8ae031
Binary files /dev/null and b/dagger-sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/dagger-sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/dagger-sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..2c18de9
Binary files /dev/null and b/dagger-sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/dagger-sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/dagger-sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..beed3cd
Binary files /dev/null and b/dagger-sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/dagger-sample/src/main/res/values/colors.xml b/dagger-sample/src/main/res/values/colors.xml
new file mode 100644
index 0000000..69b2233
--- /dev/null
+++ b/dagger-sample/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #008577
+ #00574B
+ #D81B60
+
diff --git a/dagger-sample/src/main/res/values/strings.xml b/dagger-sample/src/main/res/values/strings.xml
new file mode 100644
index 0000000..89471c4
--- /dev/null
+++ b/dagger-sample/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ Hawk & Dagger 2
+
diff --git a/dagger-sample/src/main/res/values/styles.xml b/dagger-sample/src/main/res/values/styles.xml
new file mode 100644
index 0000000..5885930
--- /dev/null
+++ b/dagger-sample/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/hawk-dagger/build.gradle b/hawk-dagger/build.gradle
new file mode 100644
index 0000000..b64017b
--- /dev/null
+++ b/hawk-dagger/build.gradle
@@ -0,0 +1,30 @@
+apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
+apply plugin: 'kotlin-kapt'
+
+android {
+ compileSdkVersion rootProject.ext.compileSdkVersion
+
+ defaultConfig {
+ minSdkVersion rootProject.ext.minSdkVersion
+ targetSdkVersion rootProject.ext.targetSdkVersion
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+}
+
+dependencies {
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
+ implementation 'com.google.dagger:dagger:2.16'
+ kapt 'com.google.dagger:dagger-compiler:2.16'
+ implementation project(':hawk')
+}
+
+apply from: rootProject.file('gradle/maven_push.gradle')
\ No newline at end of file
diff --git a/hawk-dagger/gradle.properties b/hawk-dagger/gradle.properties
new file mode 100644
index 0000000..94c6544
--- /dev/null
+++ b/hawk-dagger/gradle.properties
@@ -0,0 +1,23 @@
+# suppress inspection "UnusedProperty" for whole file
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+
+POM_NAME=Hawker, the Hawk with Dagger 2 support
+POM_ARTIFACT_ID=hawk-dagger
+POM_PACKAGING=aar
\ No newline at end of file
diff --git a/hawk-dagger/proguard-rules.pro b/hawk-dagger/proguard-rules.pro
new file mode 100644
index 0000000..f1b4245
--- /dev/null
+++ b/hawk-dagger/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/hawk-dagger/src/main/AndroidManifest.xml b/hawk-dagger/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..3a3418b
--- /dev/null
+++ b/hawk-dagger/src/main/AndroidManifest.xml
@@ -0,0 +1 @@
+
diff --git a/hawk-dagger/src/main/java/com/orhanobut/hawk/dagger/Hawker.kt b/hawk-dagger/src/main/java/com/orhanobut/hawk/dagger/Hawker.kt
new file mode 100644
index 0000000..fe100a4
--- /dev/null
+++ b/hawk-dagger/src/main/java/com/orhanobut/hawk/dagger/Hawker.kt
@@ -0,0 +1,34 @@
+package com.orhanobut.hawk.dagger
+
+import android.annotation.SuppressLint
+import android.content.Context
+import com.orhanobut.hawk.DefaultHawkFacade
+import com.orhanobut.hawk.HawkBuilder
+import com.orhanobut.hawk.HawkFacade
+import javax.inject.Inject
+import javax.inject.Singleton
+
+@SuppressLint("StaticFieldLeak")
+@Singleton
+class Hawker @Inject constructor(context: Context) {
+ private var hawkFacade: HawkFacade = DefaultHawkFacade(HawkBuilder(context))
+
+ fun put(key: String, value: T): Boolean = hawkFacade.put(key, value) ?: false
+
+ fun get(key: String): T? = hawkFacade.get(key)
+
+ fun get(key: String, defaultValue: T): T =
+ hawkFacade.get(key, defaultValue) ?: defaultValue
+
+ fun count(): Long = hawkFacade.count() ?: 0
+
+ fun deleteAll(): Boolean = hawkFacade.deleteAll() ?: false
+
+ fun delete(key: String): Boolean = hawkFacade.delete(key) ?: false
+
+ fun contains(key: String): Boolean = hawkFacade.contains(key) ?: false
+
+ fun destroy() {
+ hawkFacade.destroy()
+ }
+}
diff --git a/settings.gradle b/settings.gradle
index 5e812f4..d487841 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':hawk', ':benchmark'
+include ':hawk', ':benchmark', ':hawk-dagger', ':dagger-sample'