Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DetailLiga : AppCompatActivity(),LigaView {
- private lateinit var imgBadge : ImageView
- private lateinit var ligaStr : TextView
- private lateinit var ligaDesc : TextView
- private var ligas : MutableList<Liga> = mutableListOf()
- private lateinit var presenter:LigaPresenter
- private lateinit var progressBar:ProgressBar
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- linearLayout {
- lparams(width= matchParent,height = wrapContent)
- orientation = LinearLayout.VERTICAL
- padding = dip(16)
- linearLayout{
- lparams(width= matchParent, height = wrapContent)
- orientation = LinearLayout.HORIZONTAL
- imgBadge = imageView{
- imageResource = R.drawable.english_league_1
- }.lparams(width=dip(100),height = dip(100))
- linearLayout{
- lparams(width= matchParent,height = wrapContent)
- ligaStr = textView()
- .lparams(width= matchParent, height = wrapContent){
- bottomMargin = dip(16)
- }
- scrollView{
- lparams(width= matchParent, height=dip(150))
- ligaDesc = textView()
- .lparams(width= matchParent,height = wrapContent)
- }
- }
- }
- progressBar = progressBar{
- }.lparams{
- }
- }
- val req = ApiRepository()
- val gson = Gson()
- presenter = LigaPresenter(this, req, gson)
- presenter.getLiga("4396")
- /* Bagian ini juga error
- if(ligas[0].idLiga == null){
- hideLoading()
- toast("No data")
- } else {
- ligaStr.text = ligas[0].namaLiga
- ligaDesc.text = ligas[0].desc
- }
- */
- }
- override fun showLiga(data: List<Liga>) {
- ligas.clear()
- ligas.addAll(data)
- }
- override fun showLoading() {
- progressBar.visible()
- }
- override fun hideLoading() {
- progressBar.invisible()
- }
- fun View.visible(){
- visibility = View.VISIBLE
- }
- fun View.invisible(){
- visibility = View.INVISIBLE
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement