功能优化
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.sw.dualscreen.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import com.sw.dualscreen.R
|
||||
import com.sw.dualscreen.ext.dp
|
||||
import com.sw.dualscreen.ext.hideKeyboard
|
||||
|
||||
abstract class BaseDialog(
|
||||
context: Context,
|
||||
var defWidth: Int = 400.dp,
|
||||
var defHeight: Int = 300.dp
|
||||
) : Dialog(context, R.style.DialogTheme) {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val rootView = getRootView()
|
||||
setContentView(rootView)
|
||||
setCancelable(false)
|
||||
setCanceledOnTouchOutside(false)
|
||||
window?.apply {
|
||||
setLayout(defWidth, defHeight)
|
||||
setBackgroundDrawable(ColorDrawable())
|
||||
setGravity(Gravity.CENTER)
|
||||
}
|
||||
rootView.setOnClickListener { it.hideKeyboard() }
|
||||
initView()
|
||||
}
|
||||
|
||||
abstract fun getRootView(): View
|
||||
|
||||
abstract fun initView()
|
||||
|
||||
// fun getReceiptActivity(): GoodsListActivity? {
|
||||
// var ctx = context
|
||||
// while (ctx is ContextWrapper) {
|
||||
// ctx = ctx.baseContext
|
||||
// if (ctx is GoodsListActivity) {
|
||||
// return ctx
|
||||
// }
|
||||
// }
|
||||
// return null
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user