package com.ydl.component.music

import com.ydl.component.R
import com.ydl.component.mvp.DemoContract
import com.ydl.component.mvp.DemoPresenter
import com.ydl.ydlcommon.mvp.lce.BaseLceActivity

class MusicPlayActivity  : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(), DemoContract.View {
    override fun getContentViewId(): Int {
        return R.id.lce_content_view
    }

    override fun getStateViewId(): Int {
        return R.id.lce_state_view
    }

    private var mPlayFragment: PlayFragment? = null

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

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

    override fun initDataAndEvent() {
        reLoadData()
    }

    override fun reLoadData() {
        mPresenter.loadFmMusic()
    }

    override fun setData(data: String) {
        val ft = supportFragmentManager.beginTransaction()
        ft.setCustomAnimations(R.anim.fragment_slide_up, 0)
        if (mPlayFragment == null) {
            mPlayFragment = PlayFragment()
            ft.replace(android.R.id.content, mPlayFragment)
        } else {
            ft.show(mPlayFragment)
        }
        ft.commitAllowingStateLoss()
    }
}
