Skip to content

Commit b7f7068

Browse files
author
Arkadii Ivanov
committed
Added sample project
1 parent 64ac39a commit b7f7068

File tree

75 files changed

+1797
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1797
-10
lines changed

gradle.properties

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ org.gradle.jvmargs=-Xmx1536m
1111
# This option should only be used with decoupled projects. More details, visit
1212
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1313
# org.gradle.parallel=true
14-
15-
kotlin_version=1.2.50
14+
kotlin_version=1.2.51
1615
support_library_version=27.1.1
16+
android_arch_lifecycle_java8_version=1.1.1
17+
constraint_layout_version=1.1.2
18+
rx_java_version=2.0.2
19+
rx_relay_version=2.0.0
20+
junit_version=4.12
21+
mockito_kotlin_version=1.6.0
22+
mockito_core_version=2.19.0
23+
toothpick_version=1.1.3

mvidroid/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
*.iml
22
/build
3-

mvidroid/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ dependencies {
2222
implementation fileTree(dir: 'libs', include: ['*.jar'])
2323
implementation "com.android.support:support-annotations:$support_library_version"
2424
implementation "com.android.support:appcompat-v7:$support_library_version"
25-
implementation 'android.arch.lifecycle:common-java8:1.1.1'
25+
implementation "android.arch.lifecycle:common-java8:$android_arch_lifecycle_java8_version"
2626
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
27-
api 'io.reactivex.rxjava2:rxandroid:2.0.2'
28-
api 'com.jakewharton.rxrelay2:rxrelay:2.0.0'
29-
testImplementation 'junit:junit:4.12'
30-
testImplementation "com.nhaarman:mockito-kotlin:1.6.0"
31-
testImplementation "org.mockito:mockito-core:2.19.0"
27+
api "io.reactivex.rxjava2:rxandroid:$rx_java_version"
28+
api "com.jakewharton.rxrelay2:rxrelay:$rx_relay_version"
29+
testImplementation "junit:junit:$junit_version"
30+
testImplementation "com.nhaarman:mockito-kotlin:$mockito_kotlin_version"
31+
testImplementation "org.mockito:mockito-core:$mockito_core_version"
3232
}
3333

3434
task sourceJar(type: Jar) {

sample/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.iml
2+
/build

sample/build.gradle

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
apply plugin: 'kotlin-kapt'
5+
6+
android {
7+
compileSdkVersion 27
8+
9+
defaultConfig {
10+
applicationId "com.arkivanov.mvidroid.sample"
11+
minSdkVersion 21
12+
targetSdkVersion 27
13+
versionCode 1
14+
versionName "1.0"
15+
}
16+
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
24+
compileOptions {
25+
sourceCompatibility JavaVersion.VERSION_1_8
26+
targetCompatibility JavaVersion.VERSION_1_8
27+
}
28+
}
29+
30+
dependencies {
31+
implementation fileTree(dir: 'libs', include: ['*.jar'])
32+
implementation project(':mvidroid')
33+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
34+
implementation "com.android.support:appcompat-v7:$support_library_version"
35+
implementation "com.android.support:design:$support_library_version"
36+
implementation "com.android.support.constraint:constraint-layout:$constraint_layout_version"
37+
implementation "com.github.stephanenicolas.toothpick:toothpick-runtime:$toothpick_version"
38+
kapt "com.github.stephanenicolas.toothpick:toothpick-compiler:$toothpick_version"
39+
testImplementation "junit:junit:$junit_version"
40+
}

sample/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="com.arkivanov.mvidroid.sample"
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools">
5+
6+
<application
7+
android:name=".app.App"
8+
android:allowBackup="false"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme"
14+
tools:ignore="GoogleAppIndexingWarning">
15+
16+
<activity android:name=".ui.list.ListActivity">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
<category android:name="android.intent.category.LAUNCHER" />
20+
</intent-filter>
21+
</activity>
22+
23+
<activity
24+
android:name=".ui.details.DetailsActivity"
25+
android:label="@string/details" />
26+
</application>
27+
</manifest>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.arkivanov.mvidroid.sample.app
2+
3+
import android.app.Application
4+
import com.arkivanov.mvidroid.sample.component.app.AppComponent
5+
import toothpick.Scope
6+
import toothpick.Toothpick
7+
8+
class App : Application() {
9+
10+
lateinit var scope: Scope
11+
private set
12+
13+
private lateinit var appComponent: AppComponent
14+
15+
companion object {
16+
const val SCOPE_NAME = "APP_SCOPE"
17+
}
18+
19+
override fun onCreate() {
20+
super.onCreate()
21+
22+
scope = Toothpick.openScopes(SCOPE_NAME)
23+
scope.installModules(AppModule(this))
24+
25+
appComponent = AppComponent.create(scope)
26+
}
27+
28+
override fun onTerminate() {
29+
appComponent.dispose()
30+
Toothpick.closeScope(SCOPE_NAME)
31+
32+
super.onTerminate()
33+
}
34+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.arkivanov.mvidroid.sample.app
2+
3+
import android.content.Context
4+
import com.arkivanov.mvidroid.sample.component.Labels
5+
import com.arkivanov.mvidroid.sample.database.todo.TodoDatabase
6+
import com.arkivanov.mvidroid.sample.database.todo.TodoDatabaseImpl
7+
import com.arkivanov.mvidroid.sample.datasource.todo.TodoDataSource
8+
import com.arkivanov.mvidroid.sample.datasource.todo.TodoDataSourceImpl
9+
import com.arkivanov.mvidroid.store.factory.MviDefaultStoreFactory
10+
import com.arkivanov.mvidroid.store.factory.MviStoreFactory
11+
import com.jakewharton.rxrelay2.PublishRelay
12+
import com.jakewharton.rxrelay2.Relay
13+
import toothpick.config.Module
14+
15+
class AppModule(context: Context) : Module() {
16+
17+
init {
18+
bind(Context::class.java).toInstance(context)
19+
bind(DatabaseOpenHelper::class.java).singletonInScope()
20+
bind(TodoDatabase::class.java).to(TodoDatabaseImpl::class.java).singletonInScope()
21+
bind(TodoDataSource::class.java).to(TodoDataSourceImpl::class.java).singletonInScope()
22+
bind(MviStoreFactory::class.java).toInstance(MviDefaultStoreFactory)
23+
bind(Relay::class.java).withName(Labels::class.java).toProviderInstance { PublishRelay.create<Any>() }.providesSingletonInScope()
24+
}
25+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.arkivanov.mvidroid.sample.app
2+
3+
import android.content.Context
4+
import android.database.sqlite.SQLiteDatabase
5+
import android.database.sqlite.SQLiteOpenHelper
6+
import com.arkivanov.mvidroid.sample.database.todo.TodoDatabaseContract
7+
import javax.inject.Inject
8+
9+
class DatabaseOpenHelper @Inject constructor(context: Context) : SQLiteOpenHelper(context, "Todo", null, 1) {
10+
11+
private companion object : TodoDatabaseContract
12+
13+
override fun onCreate(db: SQLiteDatabase) {
14+
createTodoTable(db)
15+
}
16+
17+
override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
18+
}
19+
}

0 commit comments

Comments
 (0)