package com.cr.pages import android.content.Context import android.os.Handler import android.os.Looper import android.view.View import androidx.fragment.app.Fragment import com.cr.dialog.DialogNormal /** * 操作系统:MAC系统 * 创建者:王成 * 创建日期:2023/4/11 14:12 * 描述:Fragment 公共基础类 */ open class CrFragment :Fragment(){ // define: 2023/3/10 创建主线程Looper protected var mainHandler = Handler(Looper.getMainLooper()) // define: 2023/3/14 挂接的主视图 protected var mainView: View? = null // define: 2023/4/3 定义自身引用 protected var self: Fragment? = null /** * 关联控件 */ open fun joinControls() { // todo: 2023/3/31 初始化控件 initControls() } /** * 初始化控件 */ open fun initControls() { } /** * 初始化页面 */ open fun initPage() { } /** * 显示警告消息 * @param warning String 警告消息 */ protected fun showWarning(warning: String) { DialogNormal(context!!, "警告", warning).show() } /** * 显示错误信息 * @param error String 错误消息 */ protected fun showError(error: String) { DialogNormal(context!!, "错误", error).show() } /** * 显示提示信息 * @param information String 提示消息 */ protected fun showInformation(information: String) { DialogNormal(context!!, "提示", information).show() } /** * 获取上下文 * @return Context? */ override fun getContext(): Context? { return mainView!!.context } }