Permalink
Browse files

Merge branch 'feature/kotlinAndroidExtensions' into develop

  • Loading branch information...
gonzapico committed Apr 22, 2017
2 parents ae6d2b0 + 80b7ab5 commit 5d3367918af11b7a3f3337fded65049d449cd3af
View
@@ -1,5 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 25
@@ -2,7 +2,7 @@ package xyz.gonzapico.myfirstkotlinapp
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.RecyclerView
import kotlinx.android.synthetic.main.activity_home.*
class HomeActivity : AppCompatActivity() {
@@ -11,8 +11,8 @@ class HomeActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
val recyclerView = find<RecyclerView>(R.id.recycler)
recyclerView.adapter = MediaAdapter(fetchMedia())
// id = recycler
recycler.adapter = MediaAdapter(fetchMedia())
}
}
@@ -3,9 +3,9 @@ package xyz.gonzapico.myfirstkotlinapp
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
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
/**
* Created by gfernandez on 22/04/17.
@@ -25,16 +25,13 @@ class MediaAdapter(
mediaItemList.size
class MediaViewHolder(mediaView: View) : RecyclerView.ViewHolder(mediaView) {
val title = find<TextView>(R.id.media_title)
val thumb = find<ImageView>(R.id.media_thumb)
val indicator = find<ImageView>(R.id.media_video_indicator)
fun bind(item: MediaItem) {
title.text = item.title
thumb.loadUrl(item.thumbUrl)
indicator.visible = item.type == MediaItem.TYPE.VIDEO
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(title.text.toString(), Toast.LENGTH_LONG) }
itemView.setOnClickListener { showToast(item.title, Toast.LENGTH_LONG) }
}
}
}

0 comments on commit 5d33679

Please sign in to comment.