package safeluck.drive.evaluation.customview
|
|
import android.graphics.Color
|
import android.graphics.drawable.ColorDrawable
|
import android.os.Build
|
import android.os.Bundle
|
import android.view.LayoutInflater
|
import android.view.View
|
import android.view.ViewGroup
|
import android.view.WindowManager
|
import android.widget.Button
|
import android.widget.TextView
|
import androidx.fragment.app.DialogFragment
|
import safeluck.drive.evaluation.R
|
|
/**
|
*
|
* @ProjectName: DriveJudge
|
* @Package: safeluck.drive.evaluation.customview
|
* @ClassName: MyDialog
|
* @Description: java类作用描述
|
* @Author: 李占伟
|
* @CreateDate: 2020-04-29 16:46
|
* @UpdateUser: 更新者
|
* @UpdateDate: 2020-04-29 16:46
|
* @UpdateRemark: 更新说明
|
* @Version: 1.0
|
*/
|
|
class MyDialog : DialogFragment() {
|
lateinit var button: Button
|
lateinit var button_cancle: Button
|
lateinit var textview: TextView
|
var mess: String? = null
|
lateinit var onClick:MyOnClickListener
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
if(dialog!=null){
|
var windown = dialog!!.window;
|
windown?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
windown?.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
|
dialog?.setOnShowListener { windown?.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
|
hideBottomUIMenu()}
|
}
|
var view = inflater.inflate(R.layout.layout_dlg,container,false)
|
initView(view)
|
|
return view
|
}
|
|
private fun initView(view: View?) {
|
mess = arguments?.getString("message")
|
button = view!!.findViewById(R.id.btn_sure_)
|
textview = view!!.findViewById(R.id.tv_message)
|
textview.text =mess
|
button_cancle = view!!.findViewById(R.id.btn_cancle_)
|
button.setOnClickListener { onClick.onSure()
|
dismiss() }
|
button_cancle.setOnClickListener {
|
onClick.onCancle()
|
dismiss()
|
}
|
|
}
|
|
/**
|
* 隐藏虚拟按键,并且全屏
|
*/
|
protected fun hideBottomUIMenu() { //隐藏虚拟按键,并且全屏
|
if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
|
val v = this.dialog?.window?.decorView
|
v?.systemUiVisibility = View.GONE
|
} else if (Build.VERSION.SDK_INT >= 19) { //for new api versions.
|
val decorView = dialog?.window?.decorView
|
val uiOptions = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or View.SYSTEM_UI_FLAG_FULLSCREEN)
|
decorView?.systemUiVisibility = uiOptions
|
}
|
}
|
|
companion object{
|
fun newInstance(message:String):MyDialog{
|
var myDialog= MyDialog()
|
var bundle = Bundle()
|
bundle.putString("message",message)
|
myDialog.arguments = bundle
|
return myDialog
|
|
}
|
}
|
|
interface MyOnClickListener{
|
fun onSure()
|
fun onCancle()
|
}
|
|
|
|
}
|