package cn.flightfeather.thirdapp
|
|
|
import android.os.Bundle
|
import android.support.v4.app.Fragment
|
import android.view.LayoutInflater
|
import android.view.View
|
import android.view.ViewGroup
|
|
/**
|
* @author riku
|
* 2019.3.29
|
*/
|
abstract class BaseFragment : Fragment() {
|
|
protected var rootView: View? = null
|
protected var inflater: LayoutInflater? = null
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
savedInstanceState: Bundle?): View? {
|
if (rootView != null) {
|
val parentView = rootView?.parent as ViewGroup
|
parentView.removeView(rootView)
|
} else {
|
rootView = inflater.inflate(getLayoutId(), container, false)
|
this.inflater = inflater
|
initView()
|
initData()
|
}
|
return rootView
|
}
|
|
protected abstract fun getLayoutId(): Int
|
|
protected abstract fun initView()
|
|
protected abstract fun initData()
|
|
}
|