package com.fastcashier.lib_common.base

import android.view.KeyEvent
import androidx.appcompat.app.AppCompatActivity
import dmax.dialog.SpotsDialog


open class BaseActivity : AppCompatActivity() {

    private var dialog: android.app.AlertDialog? = null

    fun showProgressDialog(message:String?){
        message?.let {
            if(null == dialog){
                dialog = SpotsDialog.Builder()
                    .setContext(this)
                    .setCancelable(false)
                    .build()
            }
            dialog?.setMessage(it)
            dialog?.show()
        }
    }

    fun dismissProgressDialog(){
        dialog?.dismiss()
    }

    override fun onStop() {
        super.onStop()
        dismissProgressDialog()
    }

    override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
        return keyCode == KeyEvent.KEYCODE_BACK
    }

}