permanar

next match presenter

Nov 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.85 KB | None | 0 0
  1. package com.oende.futbolapps.main
  2.  
  3. import com.oende.futbolapps.api.TheSportDBApi
  4. import com.oende.futbolapps.api.ApiRepository
  5. import com.google.gson.Gson
  6. import com.oende.futbolapps.model.NextMatchResponse
  7. import org.jetbrains.anko.doAsync
  8. import org.jetbrains.anko.uiThread
  9.  
  10. class NextMatchPresenter(private val view: NextMatchView,
  11.                          private val apiRepository: ApiRepository,
  12.                          private val gson: Gson) {
  13.  
  14.     fun getNextMatchList() {
  15.         view.showLoading()
  16.         doAsync {
  17.             val data = gson.fromJson(apiRepository
  18.                 .doRequest(TheSportDBApi.getUpcomingMatch()),
  19.                 NextMatchResponse::class.java
  20.             )
  21.  
  22.             uiThread {
  23.                 view.hideLoading()
  24.                 view.showNextMatchList(data.events)
  25.             }
  26.         }
  27.  
  28.  
  29.     }
  30. }
Add Comment
Please, Sign In to add comment