Permalink
Browse files

Merge branch 'feature/ninjaFunctions' into develop

  • Loading branch information...
gonzapico committed Apr 22, 2017
2 parents 5d33679 + e3cc2fe commit e61f6cf06b7f1b558af463f47dcf1f250e65f8d8
Showing with 18 additions and 6 deletions.
  1. +18 −6 app/src/main/java/xyz/gonzapico/myfirstkotlinapp/MediaAdapter.kt
@@ -3,6 +3,7 @@ package xyz.gonzapico.myfirstkotlinapp
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import android.widget.Toast
import kotlinx.android.synthetic.main.view_media_item.view.*
import kotlinx.android.synthetic.main.view_media_item.view.media_title as mediaTitle
@@ -26,12 +27,23 @@ class MediaAdapter(
class MediaViewHolder(mediaView: View) : RecyclerView.ViewHolder(mediaView) {
fun bind(item: MediaItem) {
itemView.mediaTitle.text = item.title
itemView.media_thumb.loadUrl(item.thumbUrl)
itemView.media_video_indicator.visible = item.type == MediaItem.TYPE.VIDEO
// indicator.visibility = if (item.type == MediaItem.TYPE.VIDEO) View.VISIBLE else View.GONE
itemView.setOnClickListener { showToast(item.title, Toast.LENGTH_LONG) }
fun bind(item: MediaItem) = with(itemView) {
mediaTitle.text = item.title
media_thumb.loadUrl(item.thumbUrl)
media_video_indicator.visible = item.type == MediaItem.TYPE.VIDEO
setOnClickListener { showToast(item.title, Toast.LENGTH_LONG) }
// Java
val tv = TextView(itemView.context)
tv.text = "a comer"
tv.textSize = 20f
// Kotlin
val tv2 = TextView(itemView.context).apply {
text = "a comer"
textSize = 20f
}
// it returns itself
}
}
}

0 comments on commit e61f6cf

Please sign in to comment.