package com.ydl.component

import com.alibaba.android.arouter.launcher.ARouter
import com.ydl.component.mvp.DemoContract
import com.ydl.component.mvp.DemoPresenter
import com.yidianling.ydlcommon.core.mvp.lce.BaseLceActivity
import kotlinx.android.synthetic.main.activity_main.*

/**
 * Created by haorui on 2019-09-01 .
 * Des:
 */
class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(), DemoContract.View {

    override fun setData(data: String) {
        tv_content.text = data
    }

    override fun createPresenter(): DemoContract.Presenter {
        return DemoPresenter()
    }

    override fun layoutResId(): Int {
        return R.layout.activity_main
    }

    override fun initDataAndEvent() {
        loadData()

        tv_user.setOnClickListener {
            loadData()
        }

        tv_home.setOnClickListener {
            mPresenter?.loadHome()
        }

        bt_to_other.setOnClickListener {
            ARouter.getInstance().build("/other/MainActivity").navigation()
        }
    }

    override fun loadData() {
        mPresenter?.loadUsers()
    }
}
