Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
.idea
6 changes: 0 additions & 6 deletions .idea/__vcs.xml

This file was deleted.

18 changes: 0 additions & 18 deletions .idea/gradle.xml

This file was deleted.

33 changes: 0 additions & 33 deletions .idea/misc.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/modules.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

64 changes: 41 additions & 23 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
project.ext {
appcompat = "25.3.1"
arch = "1.0.0-alpha1"
retrofit = "2.0.2"
constraintLayout = "1.0.2"
dagger_version = "2.11"
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.example.test.mvvm_sample_app"
minSdkVersion 19
targetSdkVersion 25
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -25,7 +19,6 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

dataBinding {
enabled = true
}
Expand All @@ -35,30 +28,55 @@ android {
}
}

project.ext {
appcompat = "27.0.2"
arch = "1.0.0"
retrofit = "2.3.0"
constraintLayout = "1.0.2"
dagger_version = "2.13"
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// kotlin
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
kapt "com.android.databinding:compiler:3.1.0-alpha08"

// google support libraries
compile "com.android.support:appcompat-v7:$project.appcompat"
compile "com.android.support:cardview-v7:$project.appcompat"
compile "com.android.support:recyclerview-v7:$project.appcompat"
compile "com.android.support.constraint:constraint-layout:$project.constraintLayout"
compile "com.android.support:support-v4:$project.appcompat"
compile "com.android.support:design:$project.appcompat"

// architecture components
compile "android.arch.lifecycle:runtime:$project.arch"
compile "android.arch.lifecycle:extensions:$project.arch"
kapt "android.arch.lifecycle:compiler:$project.arch"

// network libraries
compile "com.squareup.retrofit2:retrofit:$project.retrofit"
compile "com.squareup.retrofit2:converter-gson:$project.retrofit"
annotationProcessor "android.arch.lifecycle:compiler:$project.arch"
compile "com.android.support.constraint:constraint-layout:$project.constraintLayout"
compile "com.android.support:support-v4:$project.appcompat"

// dagger2 dependency injection
compile "com.google.dagger:dagger:$project.dagger_version"
compile "com.google.dagger:dagger-android:$project.dagger_version"
compile "com.google.dagger:dagger-android-support:$project.dagger_version"
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"

annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"

// test libraries
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.3.1'
}
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2') {
// Necessary to avoid version conflicts
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'support-annotations'
exclude module: 'recyclerview-v7'
}

}

This file was deleted.

52 changes: 52 additions & 0 deletions app/src/androidTest/java/com/example/test/mvvmsampleapp/UiTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.example.test.mvvmsampleapp

import android.support.test.espresso.Espresso.onView
import android.support.test.espresso.action.ViewActions.click
import android.support.test.espresso.assertion.ViewAssertions.matches
import android.support.test.espresso.contrib.RecyclerViewActions
import android.support.test.espresso.matcher.ViewMatchers.isDisplayed
import android.support.test.espresso.matcher.ViewMatchers.withId
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import com.example.test.mvvmsampleapp.view.ui.MainActivity
import com.example.test.mvvmsampleapp.view.viewholders.ProjectViewHolder
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith





/**
* Instrumentation test, which will execute on an Android device.
*
* @see [Testing documentation](http://d.android.com/tools/testing)
*/
@RunWith(AndroidJUnit4::class)
class UiTests {

@Rule
@JvmField
var mainActivityTestRule = ActivityTestRule<MainActivity>(MainActivity::class.java)

/**
* Lazy example test, phone should be connected to the internet.
* Ideally you need to implement a mock web server.
*/
@Before
fun waitForLoading() {
onView(withId(R.id.loading_projects)).check(matches(isDisplayed()))
Thread.sleep(1000)
}

@Test
fun clickFirstElement() {
onView(withId(R.id.project_list))
.perform(RecyclerViewActions.actionOnItemAtPosition<ProjectViewHolder>(0, click()))

onView(withId(R.id.imageView)).check(matches(isDisplayed()))
}

}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".MVVMApplication"
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/java/com/example/test/mvvmsampleapp/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.test.mvvmsampleapp

import android.app.Activity
import android.app.Application
import com.example.test.mvvmsampleapp.di.AppInjector
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasActivityInjector
import javax.inject.Inject

class App : Application(), HasActivityInjector {

@Inject
lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Activity>

override fun onCreate() {
super.onCreate()
AppInjector.init(this)
}

override fun activityInjector(): DispatchingAndroidInjector<Activity>? {
return dispatchingAndroidInjector
}
}

This file was deleted.

This file was deleted.

Loading