<file_sep>package com.example.jadwalsholatkotlin.model

import com.google.gson.annotations.SerializedName

data class ResponseTeam(

	@field:SerializedName("sports")
	val sports: List<SportsItem>? = null
)<file_sep>package com.example.jadwalsholatkotlin

import com.example.jadwalsholatkotlin.model.ResponseTeam
import com.example.jadwalsholatkotlin.network.ApiClient
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

class MainPresenter (model : MainInterface.View) : MainInterface.Presenter{


    var view : MainInterface.View = model

    override fun getDataTeams() {
        val apiInterface = ApiClient.create()
        apiInterface.getData().enqueue(object : Callback<ResponseTeam> {
            override fun onResponse(call: Call<ResponseTeam>, response: Response<ResponseTeam>) {
                val responseTeam = response.body()
                view.showData(responseTeam?.sports!!)
            }

            override fun onFailure(call: Call<ResponseTeam>, t: Throwable) {

            }

        })
    }
}<file_sep>package com.example.jadwalsholatkotlin.model

import com.google.gson.annotations.SerializedName

data class SportsItem(

	@field:SerializedName("idSport")
	val idSport: String? = null,

	@field:SerializedName("strSport")
	val strSport: String? = null,

	@field:SerializedName("strSportThumb")
	val strSportThumb: String? = null,

	@field:SerializedName("strSportDescription")
	val strSportDescription: String? = null
)<file_sep>package com.example.jadwalsholatkotlin

import com.example.jadwalsholatkotlin.model.SportsItem

interface MainInterface {
    interface View {
        fun showData(data: List<SportsItem>)
    }
    interface Presenter {
        fun getDataTeams()
    }
}<file_sep>package com.example.jadwalsholatkotlin.adapter

import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.example.jadwalsholatkotlin.R
import com.example.jadwalsholatkotlin.model.SportsItem
import kotlinx.android.synthetic.main.item_team.view.*

class MainAdapter (val context: Context, val result : List<SportsItem>) : RecyclerView.Adapter<MainAdapter.ViewHolder>() {
    override fun onCreateViewHolder(p0: ViewGroup, p1: Int): MainAdapter.ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_team, p0, false)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return result.size
    }

    override fun onBindViewHolder(p0: MainAdapter.ViewHolder, p1: Int) {
        p0.bindItems(result[p1])
    }

    class ViewHolder(view : View) : RecyclerView.ViewHolder(view) {

        val textTitle = view.tv_teamTitle
        val textDetail = view.tv_teamDetail
        val gambar = view.img_team

        fun bindItems(item : SportsItem) {
            textTitle.text = item.strSport
            textDetail.text = item.strSportDescription
            Glide.with(itemView.context)
                .load(item.strSportThumb)
                .into(gambar)
        }
    }
}<file_sep>package com.example.jadwalsholatkotlin.network

import com.example.jadwalsholatkotlin.model.ResponseTeam
import retrofit2.Call
import retrofit2.http.GET

interface ApiInterface {
    @GET("api/v1/json/1/all_sports.php")
    fun getData() : Call<ResponseTeam>
}<file_sep>package com.example.jadwalsholatkotlin.network

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object ApiClient {
    private val BASE_URL = "https://www.thesportsdb.com/"

    fun create() : ApiInterface{
        val retrofit = Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .build()

        return retrofit.create(ApiInterface::class.java!!)
    }

}<file_sep>package com.example.jadwalsholatkotlin

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import com.example.jadwalsholatkotlin.adapter.MainAdapter
import com.example.jadwalsholatkotlin.model.SportsItem
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity(), MainInterface.View {

    val presenter = MainPresenter(this)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        presenter.getDataTeams()
    }

    override fun showData(data: List<SportsItem>) {
        rec_main.adapter = MainAdapter(this, data)
        rec_main.layoutManager = LinearLayoutManager(this)
    }
}
