package com.cooleshow.base.ui.activity

import android.os.Bundle
import android.view.View
import android.widget.FrameLayout
import com.cooleshow.base.common.AppManager
import com.cooleshow.base.utils.helper.QMUIStatusBarHelper
import com.trello.rxlifecycle4.components.support.RxAppCompatActivity

/*
    Activity基类，业务无关
 */
abstract class BaseActivity : RxAppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getLayoutId())
        initView();
        AppManager.instance.addActivity(this)
        QMUIStatusBarHelper.translucent(this)
    }

    protected abstract fun getLayoutId(): Int

    protected abstract fun initView()

    override fun onDestroy() {
        super.onDestroy()

        AppManager.instance.finishActivity(this)
    }


    //获取Window中视图content
    val contentView: View
        get() {
            val content = findViewById<FrameLayout>(android.R.id.content)
            return content.getChildAt(0)
        }
}
