diff --git a/app/build.gradle b/app/build.gradle index 42adbf2..cba598c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,12 +1,12 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'shot' +apply plugin: "com.android.application" +apply plugin: "kotlin-android" +apply plugin: "kotlin-android-extensions" +apply plugin: "shot" android { compileSdkVersion 28 defaultConfig { - applicationId "com.karumi" + applicationId "com.karumi.superheroes.jetpack" minSdkVersion 16 targetSdkVersion 28 versionCode 1 @@ -30,7 +30,7 @@ configurations { dependencies { /* Lint */ - ktlint 'com.github.shyiko:ktlint:0.29.0' + ktlint "com.github.shyiko:ktlint:0.29.0" /* Kotlin */ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" @@ -45,15 +45,15 @@ dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.0" /* DI */ - implementation 'org.kodein.di:kodein-di-erased-jvm:6.0.1' - implementation 'org.kodein.di:kodein-di-framework-android-x:6.0.1' + implementation "org.kodein.di:kodein-di-erased-jvm:6.0.1" + implementation "org.kodein.di:kodein-di-framework-android-x:6.0.1" /* UI */ - implementation 'com.squareup.picasso:picasso:2.5.2' + implementation "com.squareup.picasso:picasso:2.5.2" implementation "com.google.android.material:material:1.0.0" /* Testing */ - testImplementation 'junit:junit:4.12' + testImplementation "junit:junit:4.12" testImplementation "org.mockito:mockito-core:2.23.4" androidTestImplementation "org.mockito:mockito-android:2.23.4" androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0" @@ -64,16 +64,16 @@ dependencies { } androidTestImplementation "com.android.support.test.espresso:espresso-intents:3.0.2" - androidTestImplementation('com.facebook.testing.screenshot:core:0.8.0') { - exclude group: 'com.crittercism.dexmaker', module: 'dexmaker' - exclude group: 'com.crittercism.dexmaker', module: 'dexmaker-dx' + androidTestImplementation("com.facebook.testing.screenshot:core:0.8.0") { + exclude group: "com.crittercism.dexmaker", module: "dexmaker" + exclude group: "com.crittercism.dexmaker", module: "dexmaker-dx" } androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.1.0" } shot { - appId = 'com.karumi' + appId = "com.karumi.superheroes.jetpack" } task ktlint(type: JavaExec) { diff --git a/app/screenshots/com.karumi.jetpack.superheroes.ui.view.MainActivityTest_showsEmptyCaseIfThereAreNoSuperHeroes.png b/app/screenshots/com.karumi.jetpack.superheroes.ui.view.MainActivityTest_showsEmptyCaseIfThereAreNoSuperHeroes.png index 1500e0e..2b7b895 100644 Binary files a/app/screenshots/com.karumi.jetpack.superheroes.ui.view.MainActivityTest_showsEmptyCaseIfThereAreNoSuperHeroes.png and b/app/screenshots/com.karumi.jetpack.superheroes.ui.view.MainActivityTest_showsEmptyCaseIfThereAreNoSuperHeroes.png differ diff --git a/app/src/main/java/com/karumi/jetpack/superheroes/common/TimeProviders.kt b/app/src/main/java/com/karumi/jetpack/superheroes/common/TimeProviders.kt index e92ae28..a554ae6 100644 --- a/app/src/main/java/com/karumi/jetpack/superheroes/common/TimeProviders.kt +++ b/app/src/main/java/com/karumi/jetpack/superheroes/common/TimeProviders.kt @@ -7,4 +7,3 @@ interface TimeProvider { class RealTimeProvider : TimeProvider { override val time = System.currentTimeMillis() } - diff --git a/app/src/main/java/com/karumi/jetpack/superheroes/ui/presenter/SuperHeroDetailPresenter.kt b/app/src/main/java/com/karumi/jetpack/superheroes/ui/presenter/SuperHeroDetailPresenter.kt index 956a096..b75f5db 100644 --- a/app/src/main/java/com/karumi/jetpack/superheroes/ui/presenter/SuperHeroDetailPresenter.kt +++ b/app/src/main/java/com/karumi/jetpack/superheroes/ui/presenter/SuperHeroDetailPresenter.kt @@ -35,6 +35,10 @@ class SuperHeroDetailPresenter( cancel() } + fun onEditSelected() { + view?.openEditSuperHero(id) + } + private fun refreshSuperHero() = launch { val superHero = async { getSuperHeroById(id) } ?: return@launch view?.hideLoading() @@ -46,5 +50,6 @@ class SuperHeroDetailPresenter( fun showLoading() fun hideLoading() fun showSuperHero(superHero: SuperHero) + fun openEditSuperHero(superHeroId: String) } } \ No newline at end of file diff --git a/app/src/main/java/com/karumi/jetpack/superheroes/ui/view/SuperHeroDetailActivity.kt b/app/src/main/java/com/karumi/jetpack/superheroes/ui/view/SuperHeroDetailActivity.kt index ffc9246..a55ced0 100644 --- a/app/src/main/java/com/karumi/jetpack/superheroes/ui/view/SuperHeroDetailActivity.kt +++ b/app/src/main/java/com/karumi/jetpack/superheroes/ui/view/SuperHeroDetailActivity.kt @@ -37,12 +37,7 @@ class SuperHeroDetailActivity : BaseActivity(), SuperHeroDetailPresenter.View { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - edit_super_hero.setOnClickListener { - EditSuperHeroActivity.open( - this@SuperHeroDetailActivity, - superHeroId - ) - } + edit_super_hero.setOnClickListener { presenter.onEditSelected() } } override fun onResume() { @@ -81,6 +76,10 @@ class SuperHeroDetailActivity : BaseActivity(), SuperHeroDetailPresenter.View { super_hero_background.visibility = View.VISIBLE } + override fun openEditSuperHero(superHeroId: String) { + EditSuperHeroActivity.open(this, superHeroId) + } + override val activityModules = Kodein.Module("SuperHeroDetailActivity dependencies", allowSilentOverride = true) { bind() with provider { diff --git a/app/src/main/res/layout/main_activity.xml b/app/src/main/res/layout/main_activity.xml index 5a551c9..8f4cf2e 100644 --- a/app/src/main/res/layout/main_activity.xml +++ b/app/src/main/res/layout/main_activity.xml @@ -1,5 +1,5 @@ - + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + tools:visibility="visible" /> - + diff --git a/app/src/main/res/layout/super_hero_detail_activity.xml b/app/src/main/res/layout/super_hero_detail_activity.xml index f08fa9f..7c2787d 100644 --- a/app/src/main/res/layout/super_hero_detail_activity.xml +++ b/app/src/main/res/layout/super_hero_detail_activity.xml @@ -118,7 +118,8 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + tools:visibility="visible" />