Skip to content

Commit

Permalink
Chris updates
Browse files Browse the repository at this point in the history
MagicalMeghan committed Nov 2, 2020
1 parent 309ecb2 commit 1b0a20b
Showing 8 changed files with 27 additions and 17 deletions.
9 changes: 9 additions & 0 deletions RecyclerViewKotlin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
.idea/
5 changes: 5 additions & 0 deletions RecyclerViewKotlin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#RecyclerView Kotlin

This application implements a RecyclerView in Kotlin with ListAdapter, onClickListener
and Headers. If you are looking for a simpler sample, look at the RecyclerViewSimple sample
in the directory.
2 changes: 1 addition & 1 deletion RecyclerViewKotlin/app/build.gradle
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ android {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "androidx.appcompat:appcompat:$rootProject.appCompatVersion"
implementation "androidx.core:core-ktx:$rootProject.coreKtxVersion"
implementation "androidx.constraintlayout:constraintlayout:$rootProject.constraintLayoutVersion"
Original file line number Diff line number Diff line change
@@ -47,16 +47,16 @@ class AddFlowerActivity : AppCompatActivity() {
to cancelled. */

private fun addFlower() {
val addFlowerIntent = Intent()
val resultIntent = Intent()

if (addFlowerName.text.isNullOrEmpty() || addFlowerDescription.text.isNullOrEmpty()) {
setResult(Activity.RESULT_CANCELED, addFlowerIntent)
setResult(Activity.RESULT_CANCELED, resultIntent)
} else {
val name = addFlowerName.text.toString()
val description = addFlowerDescription.text.toString()
addFlowerIntent.putExtra(FLOWER_NAME, name)
addFlowerIntent.putExtra(FLOWER_DESCRIPTION, description)
setResult(Activity.RESULT_OK, addFlowerIntent)
resultIntent.putExtra(FLOWER_NAME, name)
resultIntent.putExtra(FLOWER_DESCRIPTION, description)
setResult(Activity.RESULT_OK, resultIntent)
}
finish()
}
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ import android.content.res.Resources
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData

/* Handles operations on flowersLiveData and holds details about it. */
class DataSource(resources: Resources) {
private val initialFlowerList = flowerList(resources)
private val flowersLiveData = MutableLiveData(initialFlowerList)
14 changes: 5 additions & 9 deletions RecyclerViewKotlin/app/src/main/res/layout/flower_item.xml
Original file line number Diff line number Diff line change
@@ -15,17 +15,13 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_height="wrap_content">

<ImageView
android:id="@+id/flower_image"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="8dp"
android:contentDescription="@string/flower_image_content_description"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/flower_text"
@@ -36,7 +32,7 @@
android:id="@+id/flower_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_margin="8dp"
android:text="@string/flower1_name"
android:textAppearance="?attr/textAppearanceHeadline5"
app:layout_constraintBottom_toBottomOf="parent"
2 changes: 1 addition & 1 deletion RecyclerViewKotlin/build.gradle
Original file line number Diff line number Diff line change
@@ -47,6 +47,6 @@ ext {
recyclerViewVersion = '1.2.0-alpha06'
appCompatVersion = '1.2.0'
coreKtxVersion = '1.3.2'
constraintLayoutVersion = '2.0.2'
constraintLayoutVersion = '2.0.4'
activityVersion = '1.1.0'
}
1 change: 0 additions & 1 deletion RecyclerViewKotlin/gradle.properties
Original file line number Diff line number Diff line change
@@ -12,6 +12,5 @@ org.gradle.jvmargs=-Xmx1536m
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=false
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

0 comments on commit 1b0a20b

Please sign in to comment.