模块 | 兼容性 |
---|---|
API | ~90% |
生命周期 | 模拟 |
转场动画 | 支持 |
页面自动回收与恢复 | 支持 |
启动模式 | 未知 |
数据传输 | 支持 |
class MainActivity : PageDocker() {
override fun onGetHomePage(): Class<out PageActivity> {
return MainPageActivity::class.java
}
override fun onPreInjectRootLayout() {
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
//自定义容器布局
override fun onCustomDockerLayout(): FrameLayout? {
return super.onCustomDockerLayout()
}
}
class MainPageActivity(context: Context) : PageActivity(context) {
private val mViewBinding by lazy { MainPageActivityLayoutBinding.bind(this.getPageWindows().pageActivity) }
private var num = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main_page_activity_layout)
mViewBinding.btNext.setOnClickListener {
val intent = Intent(context,SubPageActivity::class.java)
intent.putExtra("title","标题${++num}")
startActivityForResult(intent,1)
}
mViewBinding.btShowDialog.setOnClickListener {
val dialog = HomeDialog(this)
dialog.onClick {
dialog.dismiss()
}
dialog.show()
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
}
}
class SubPageActivity(context: Context) : PageActivity(context) {
private val mViewBinding by lazy { SubPageActivityLayoutBinding.bind(this.getPageWindows().pageActivity) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.sub_page_activity_layout)
mViewBinding.btBack.setOnClickListener {
this.setResult(RESULT_OK, Intent().apply {
this.data = Uri.parse("https://www.hao123.com")
})
this.finish()
}
mViewBinding.btNewPage.setOnClickListener {
startActivity(SubPageActivity::class.java)
}
}
override fun onPreEnterStartAnim(animId: Int, function: () -> Unit) {
scaleX = 0.8f
scaleY = 0.8f
translationX = getScreenWidth().toFloat()
animate().scaleX(1f).scaleY(1f).translationX(0f).onEnd{
function()
}
}
override fun onPreExitFinishAnim(function: () -> Unit) {
animate().scaleX(0.8f).scaleY(0.8f).translationX(getScreenWidth().toFloat()).onEnd{
function()
}
}
private fun ViewPropertyAnimator.onEnd(function:()->Unit): ViewPropertyAnimator {
this.setListener(object : Animator.AnimatorListener{
override fun onAnimationStart(animation: Animator?) {
}
override fun onAnimationEnd(animation: Animator?) {
function()
}
override fun onAnimationCancel(animation: Animator?) {
}
override fun onAnimationRepeat(animation: Animator?) {
}
})
return this
}
}
@SuppressLint("ViewConstructor")
class HomeDialog(mPageActivity: BasePageActivity) : PageDialog(mPageActivity) {
override fun onCreate() {
setContentView(R.layout.home_dialog_layout)
setCancelable(false)
setCanceledOnTouchOutside(false)
listenerClick(R.id.btOk)
listenerClick(R.id.btCancel)
}
}