Skip to content

Commit

Permalink
refactor(database, firestore): remove kotlin synthetic binding (fireb…
Browse files Browse the repository at this point in the history
  • Loading branch information
thatfiredev authored Nov 30, 2020
1 parent c67035b commit a2226af
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
5 changes: 0 additions & 5 deletions database/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.kotlin.android.extensions'

check.dependsOn 'assembleDebugAndroidTest'

Expand Down Expand Up @@ -29,10 +28,6 @@ android {
}
}

androidExtensions {
experimental = true
}

dependencies {
implementation project(":internal:lintchecks")
implementation project(":internal:chooserx")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,32 @@ package com.google.firebase.quickstart.database.kotlin.viewholder

import androidx.recyclerview.widget.RecyclerView
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.google.firebase.quickstart.database.R
import com.google.firebase.quickstart.database.kotlin.models.Post
import kotlinx.android.synthetic.main.include_post_author.view.postAuthor
import kotlinx.android.synthetic.main.include_post_text.view.postBody
import kotlinx.android.synthetic.main.include_post_text.view.postTitle
import kotlinx.android.synthetic.main.item_post.view.postNumStars
import kotlinx.android.synthetic.main.item_post.view.star

class PostViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val postTitle: TextView = itemView.findViewById(R.id.postTitle)
private val postAuthor: TextView = itemView.findViewById(R.id.postAuthor)
private val postNumStars: TextView = itemView.findViewById(R.id.postNumStars)
private val postBody: TextView = itemView.findViewById(R.id.postBody)
private val star: ImageView = itemView.findViewById(R.id.star)

fun bindToPost(post: Post, starClickListener: View.OnClickListener) {
itemView.postTitle.text = post.title
itemView.postAuthor.text = post.author
itemView.postNumStars.text = post.starCount.toString()
itemView.postBody.text = post.body
postTitle.text = post.title
postAuthor.text = post.author
postNumStars.text = post.starCount.toString()
postBody.text = post.body

itemView.star.setOnClickListener(starClickListener)
star.setOnClickListener(starClickListener)
}

fun setLikedState(liked: Boolean) {
if (liked) {
itemView.star.setImageResource(R.drawable.ic_toggle_star_24)
star.setImageResource(R.drawable.ic_toggle_star_24)
} else {
itemView.star.setImageResource(R.drawable.ic_toggle_star_outline_24)
star.setImageResource(R.drawable.ic_toggle_star_outline_24)
}
}
}
5 changes: 0 additions & 5 deletions firestore/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.kotlin.android.extensions'

android {
testBuildType "release"
Expand Down Expand Up @@ -36,10 +35,6 @@ android {
}
}

androidExtensions {
experimental = true
}

dependencies {
implementation project(":internal:lintchecks")
implementation project(":internal:chooserx")
Expand Down

0 comments on commit a2226af

Please sign in to comment.