package com.qimai.android.widget

import android.content.Intent
import android.os.Bundle
import android.view.Gravity
import android.widget.Button
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.qimai.android.widgetlib.popup.QmTipOverlayDrawable
import com.qimai.android.widgetlib.toast.HolderContext
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.runBlocking
import java.lang.RuntimeException

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        HolderContext.getInstance().register { this }
        findViewById<Button>(R.id.commonPop).setOnClickListener {
            //            ToastUtils.getInstance().showCenter("测试测试")

//            ToastUtils.getInstance().setMsgColor(Color.RED).showTaost("测试出的的")

//            startActivity(Intent(MainActivity@ this, CommomPopActivity::class.java))
//            val loding = Loading()
//            loding.isCancelable  =false
//            loding.show(supportFragmentManager, "loading")

//            TestWindow(this, findViewById<Button>(R.id.commonPop)).build().show()
//            CustomToastUtils.getInstance().success()

        }
        findViewById<LinearLayout>(R.id.ll).background = QmTipOverlayDrawable(
            QmTipOverlayDrawable.Builder()
                .withContext(this)
                .withArrowShow(true)
                .withArrowWeight(0.5f)
                .withGravity(Gravity.TOP)
        )
        keyboard.bindEditText(inputText)
        findViewById<TextView>(R.id.drawer).setOnClickListener {
            startActivity(Intent(MainActivity@ this, CommomPopActivity::class.java))
        }
        findViewById<Button>(R.id.tip).setOnClickListener {
            startActivity(Intent(MainActivity@ this, TipActivity::class.java))
        }
        findViewById<Button>(R.id.topbar).setOnClickListener {
            startActivity(Intent(MainActivity@ this, TopBarActivity::class.java))
        }
        findViewById<Button>(R.id.divide).setOnClickListener {
            startActivity(Intent(MainActivity@ this, GridDividerActivity::class.java))
        }
        findViewById<Button>(R.id.btn_printer).setOnClickListener {
          //  startActivity(Intent(this, MainActivityPtinter::class.java))
        }
        findViewById<Button>(R.id.btn_log).setOnClickListener {
            startActivity(Intent(this, LogActivity::class.java))
        }
        findViewById<Button>(R.id.btn_crash).setOnClickListener {
            throw RuntimeException("主线程崩溃")
        }
        findViewById<Button>(R.id.btn_zqtool).setOnClickListener {
            startActivity(Intent(this, ZqToolActivity::class.java))
        }
        keyboard.btnText = "结账"
        keyboard.invalidate()

    }
}
