Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 2.38 KB | None | 0 0
  1. class DetailLiga : AppCompatActivity(),LigaView {
  2.     private lateinit var imgBadge : ImageView
  3.     private lateinit var ligaStr : TextView
  4.     private lateinit var ligaDesc : TextView
  5.     private var ligas : MutableList<Liga> = mutableListOf()
  6.     private lateinit var presenter:LigaPresenter
  7.     private lateinit var progressBar:ProgressBar
  8.  
  9.     override fun onCreate(savedInstanceState: Bundle?) {
  10.         super.onCreate(savedInstanceState)
  11.  
  12.         linearLayout {
  13.             lparams(width= matchParent,height = wrapContent)
  14.             orientation = LinearLayout.VERTICAL
  15.             padding = dip(16)
  16.             linearLayout{
  17.                 lparams(width= matchParent, height = wrapContent)
  18.                 orientation = LinearLayout.HORIZONTAL
  19.                 imgBadge = imageView{
  20.                     imageResource = R.drawable.english_league_1
  21.                 }.lparams(width=dip(100),height = dip(100))
  22.                 linearLayout{
  23.                     lparams(width= matchParent,height = wrapContent)
  24.                     ligaStr = textView()
  25.                         .lparams(width= matchParent, height = wrapContent){
  26.                             bottomMargin = dip(16)
  27.                         }
  28.                     scrollView{
  29.                         lparams(width= matchParent, height=dip(150))
  30.                         ligaDesc = textView()
  31.                             .lparams(width= matchParent,height = wrapContent)
  32.                     }
  33.                 }
  34.             }
  35.  
  36.             progressBar = progressBar{
  37.             }.lparams{
  38.  
  39.             }
  40.         }
  41.  
  42.         val req = ApiRepository()
  43.         val gson = Gson()
  44.         presenter = LigaPresenter(this, req, gson)
  45.         presenter.getLiga("4396")
  46.  
  47.         /* Bagian ini juga error
  48.         if(ligas[0].idLiga == null){
  49.             hideLoading()
  50.             toast("No data")
  51.         } else {
  52.             ligaStr.text = ligas[0].namaLiga
  53.             ligaDesc.text = ligas[0].desc
  54.         }
  55.         */
  56.  
  57.     }
  58.  
  59.     override fun showLiga(data: List<Liga>) {
  60.         ligas.clear()
  61.         ligas.addAll(data)
  62.     }
  63.  
  64.     override fun showLoading() {
  65.         progressBar.visible()
  66.     }
  67.  
  68.     override fun hideLoading() {
  69.         progressBar.invisible()
  70.     }
  71.  
  72.     fun View.visible(){
  73.         visibility = View.VISIBLE
  74.     }
  75.  
  76.     fun View.invisible(){
  77.         visibility = View.INVISIBLE
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement