Skip to content

Commit

Permalink
Replace RelativeLayout by ConstraintLayout. Fix linting and be more c…
Browse files Browse the repository at this point in the history
…onsistent with quote usages in build.gradle file
  • Loading branch information
Serchinastico committed Jan 30, 2019
1 parent f6956d8 commit 017629a
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 27 deletions.
28 changes: 14 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ interface TimeProvider {
class RealTimeProvider : TimeProvider {
override val time = System.currentTimeMillis()
}

Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -46,5 +50,6 @@ class SuperHeroDetailPresenter(
fun showLoading()
fun hideLoading()
fun showSuperHero(superHero: SuperHero)
fun openEditSuperHero(superHeroId: String)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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<SuperHeroDetailPresenter>() with provider {
Expand Down
22 changes: 17 additions & 5 deletions app/src/main/res/layout/main_activity.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand All @@ -12,22 +12,29 @@
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/AppTheme.AppBarOverlay"
app:layout_constraintTop_toTopOf="parent"
app:popupTheme="@style/AppTheme.PopupOverlay" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="0dp"
android:layout_below="@id/toolbar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar"
tools:context="com.karumi.screenshot.ui.view.MainActivity"
tools:listitem="@layout/super_hero_row"
tools:showIn="@layout/main_activity" />

<androidx.core.widget.ContentLoadingProgressBar
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/tv_empty_case"
Expand All @@ -36,6 +43,11 @@
android:layout_centerInParent="true"
android:text="¯\\_(ツ)_/¯"
android:textColor="@android:color/white"
android:visibility="gone" />
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" />

</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 2 additions & 1 deletion app/src/main/res/layout/super_hero_detail_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down

0 comments on commit 017629a

Please sign in to comment.