From 4cd56f267df95d26c1b2dd75995bfc1f37ea8f7f Mon Sep 17 00:00:00 2001 From: h4h13 Date: Thu, 4 Jul 2019 11:52:13 +0530 Subject: [PATCH] Wip MVP --- core/.gitignore | 1 + core/build.gradle | 44 +++++++++++++++++++ core/consumer-rules.pro | 0 core/proguard-rules.pro | 21 +++++++++ .../monkey/core/ExampleInstrumentedTest.kt | 24 ++++++++++ core/src/main/AndroidManifest.xml | 2 + .../java/code/name/monkey/core/DataManager.kt | 6 +++ .../java/code/name/monkey/core/Presenter.kt | 7 +++ .../code/name/monkey/core/PresenterImpl.kt | 13 ++++++ .../core/dagger/songs/SongsPresenter.kt | 15 +++++++ core/src/main/res/values/strings.xml | 3 ++ .../code/name/monkey/core/ExampleUnitTest.kt | 17 +++++++ settings.gradle | 2 +- 13 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 core/.gitignore create mode 100644 core/build.gradle create mode 100644 core/consumer-rules.pro create mode 100644 core/proguard-rules.pro create mode 100644 core/src/androidTest/java/code/name/monkey/core/ExampleInstrumentedTest.kt create mode 100644 core/src/main/AndroidManifest.xml create mode 100644 core/src/main/java/code/name/monkey/core/DataManager.kt create mode 100644 core/src/main/java/code/name/monkey/core/Presenter.kt create mode 100644 core/src/main/java/code/name/monkey/core/PresenterImpl.kt create mode 100644 core/src/main/java/code/name/monkey/core/dagger/songs/SongsPresenter.kt create mode 100644 core/src/main/res/values/strings.xml create mode 100644 core/src/test/java/code/name/monkey/core/ExampleUnitTest.kt diff --git a/core/.gitignore b/core/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/core/.gitignore @@ -0,0 +1 @@ +/build diff --git a/core/build.gradle b/core/build.gradle new file mode 100644 index 00000000..a1f793e0 --- /dev/null +++ b/core/build.gradle @@ -0,0 +1,44 @@ +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-kapt' +android { + compileSdkVersion 28 + buildToolsVersion "29.0.0" + + + defaultConfig { + minSdkVersion 15 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles 'consumer-rules.pro' + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.core:core-ktx:1.0.2' + + implementation 'com.google.dagger:dagger:2.11' + kapt 'com.google.dagger:dagger-compiler:2.11' + + implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' + implementation 'io.reactivex.rxjava2:rxjava:2.2.9' + + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' +} diff --git a/core/consumer-rules.pro b/core/consumer-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/core/proguard-rules.pro b/core/proguard-rules.pro new file mode 100644 index 00000000..f1b42451 --- /dev/null +++ b/core/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/core/src/androidTest/java/code/name/monkey/core/ExampleInstrumentedTest.kt b/core/src/androidTest/java/code/name/monkey/core/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..f9115a4b --- /dev/null +++ b/core/src/androidTest/java/code/name/monkey/core/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package code.name.monkey.core + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("code.name.monkey.core.test", appContext.packageName) + } +} diff --git a/core/src/main/AndroidManifest.xml b/core/src/main/AndroidManifest.xml new file mode 100644 index 00000000..2ff27a18 --- /dev/null +++ b/core/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + diff --git a/core/src/main/java/code/name/monkey/core/DataManager.kt b/core/src/main/java/code/name/monkey/core/DataManager.kt new file mode 100644 index 00000000..d5885dd7 --- /dev/null +++ b/core/src/main/java/code/name/monkey/core/DataManager.kt @@ -0,0 +1,6 @@ +package code.name.monkey.core + +import io.reactivex.Observable + +interface DataManager { +} \ No newline at end of file diff --git a/core/src/main/java/code/name/monkey/core/Presenter.kt b/core/src/main/java/code/name/monkey/core/Presenter.kt new file mode 100644 index 00000000..ffa11d4e --- /dev/null +++ b/core/src/main/java/code/name/monkey/core/Presenter.kt @@ -0,0 +1,7 @@ +package code.name.monkey.core + +interface Presenter { + fun attachView(view: T) + + fun detachView() +} \ No newline at end of file diff --git a/core/src/main/java/code/name/monkey/core/PresenterImpl.kt b/core/src/main/java/code/name/monkey/core/PresenterImpl.kt new file mode 100644 index 00000000..155692d7 --- /dev/null +++ b/core/src/main/java/code/name/monkey/core/PresenterImpl.kt @@ -0,0 +1,13 @@ +package code.name.monkey.core + +class PresenterImpl { + var view: T? = null + + fun attachView(view: T) { + this.view = view + } + + fun detachView() { + this.view = null + } +} \ No newline at end of file diff --git a/core/src/main/java/code/name/monkey/core/dagger/songs/SongsPresenter.kt b/core/src/main/java/code/name/monkey/core/dagger/songs/SongsPresenter.kt new file mode 100644 index 00000000..d915f573 --- /dev/null +++ b/core/src/main/java/code/name/monkey/core/dagger/songs/SongsPresenter.kt @@ -0,0 +1,15 @@ +package code.name.monkey.core.dagger.songs + +import code.name.monkey.core.DataManager +import code.name.monkey.core.Presenter +import javax.inject.Inject + +interface SongsPresenter : Presenter { + fun loadSongs() + + class SongsPresenterImpl @Inject constructor(private val dataManager: DataManager) +} + +interface SongView { + fun songs() +} diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml new file mode 100644 index 00000000..6f8e4f60 --- /dev/null +++ b/core/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + core + diff --git a/core/src/test/java/code/name/monkey/core/ExampleUnitTest.kt b/core/src/test/java/code/name/monkey/core/ExampleUnitTest.kt new file mode 100644 index 00000000..f3fc5be4 --- /dev/null +++ b/core/src/test/java/code/name/monkey/core/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package code.name.monkey.core + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/settings.gradle b/settings.gradle index 91441848..d170d34c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':appthemehelper' \ No newline at end of file +include ':app', ':appthemehelper', ':core' \ No newline at end of file