Skip to content

Commit

Permalink
Update movie item listener
Browse files Browse the repository at this point in the history
  • Loading branch information
adrie4mac committed Jan 22, 2019
1 parent 1625952 commit d39495a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import com.adriesavana.themoviedb.common.base.BindableListItemViewHolder
import com.adriesavana.themoviedb.databinding.ListItemMovieBinding
import com.mikepenz.fastadapter.items.AbstractItem

class MovieListItem(private val listener: OnEventClickListener?,
class MovieListItem(private val eventListener: OnEventClickListener?,
private val movieDetail: MovieDetail)
: AbstractItem<MovieListItem, MovieListItem.ViewHolder>() {

private val onClickListener = View.OnClickListener { listener?.openDetail(movieDetail) }

override fun getType(): Int = hashCode()

override fun getViewHolder(v: View): ViewHolder = ViewHolder(v)
Expand All @@ -22,16 +20,15 @@ class MovieListItem(private val listener: OnEventClickListener?,
override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
holder.binding.apply {
listener = eventListener
movieModel = movieDetail
executePendingBindings()
}

holder.itemView.setOnClickListener(onClickListener)
}

class ViewHolder(itemView: View) : BindableListItemViewHolder<ListItemMovieBinding>(itemView)

interface OnEventClickListener {
fun openDetail(movieDetail: MovieDetail)
}
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/layout/list_item_movie.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
<variable
name="movieModel"
type="com.adriesavana.movie.model.MovieDetail" />

<variable
name="listener"
type="com.adriesavana.themoviedb.movie.MovieListItem.OnEventClickListener" />
</data>

<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:elevation="4dp"
android:onClick="@{()->listener.openDetail(movieModel)}"
app:cardCornerRadius="10dp">

<android.support.constraint.ConstraintLayout
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: '../TheMovieDB/buildsystem/dependencies.gradle'
apply from: '../TheMovie/buildsystem/dependencies.gradle'


buildscript {
Expand All @@ -11,7 +11,7 @@ buildscript {
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Wed Jan 16 14:37:44 WIB 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

0 comments on commit d39495a

Please sign in to comment.