Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.oende.futbolapps.main
- import android.support.v7.widget.RecyclerView
- import android.view.View
- import android.view.ViewGroup
- import android.widget.LinearLayout
- import android.widget.TextView
- import com.oende.futbolapps.R.id.match_id
- import com.oende.futbolapps.R.id.match_title
- import com.oende.futbolapps.model.NextMatch
- import org.jetbrains.anko.*
- class NextMatchAdapter(private val teams: List<NextMatch>)
- : RecyclerView.Adapter<NextMatchViewHolder>() {
- override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NextMatchViewHolder {
- return NextMatchViewHolder(TeamUI().createView(AnkoContext.create(parent.context, parent)))
- }
- override fun onBindViewHolder(holder: NextMatchViewHolder, position: Int) {
- holder.bindItem(teams[position])
- }
- override fun getItemCount(): Int = teams.size
- }
- class TeamUI : AnkoComponent<ViewGroup> {
- override fun createView(ui: AnkoContext<ViewGroup>): View {
- return with(ui) {
- linearLayout {
- lparams(width = matchParent, height = wrapContent)
- padding = dip(16)
- orientation = LinearLayout.HORIZONTAL
- textView {
- id = match_id
- }.lparams{
- height = dip(50)
- width = dip(50)
- }
- textView {
- id = match_title
- textSize = 16f
- }.lparams{
- margin = dip(15)
- }
- }
- }
- }
- }
- class NextMatchViewHolder(view: View) : RecyclerView.ViewHolder(view){
- private val matchId: TextView = view.find(match_id)
- private val matchTitle: TextView = view.find(match_title)
- fun bindItem(teams: NextMatch) {
- // Picasso.get().load(teams.matchId).into(teamBadge)
- matchId.text = teams.matchId
- matchTitle.text = teams.matchTitle
- }
- }
Add Comment
Please, Sign In to add comment