package com.miya.fastcashier.log

import android.content.Intent
import android.os.Bundle
import com.fastcashier.lib_common.base.BaseActivity
import com.fastcashier.lib_common.util.LogFileUtils
import com.fastcashier.lib_common.util.clickWithTrigger
import com.miya.fastcashier.databinding.ActivityFunctionCenterBinding
import com.miya.fastcashier.ui.dialog.SystemParameterDialog

/**
 * 功能中心
 * @author zpxiang
 */
class FunctionCenterActivity : BaseActivity() {

    private lateinit var viewBinding: ActivityFunctionCenterBinding
    private var systemDialog: SystemParameterDialog? = null

    companion object {
        fun start(context: BaseActivity) {
            var intent = Intent()
            intent.setClass(context, FunctionCenterActivity::class.java)
            context.startActivity(intent)
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        viewBinding = ActivityFunctionCenterBinding.inflate(layoutInflater)
        setContentView(viewBinding.root)

        viewBinding.moreOpExit.clickWithTrigger { finish() }
        viewBinding.vLog.clickWithTrigger { toUploadLog() }
        viewBinding.vSystem.clickWithTrigger { showSystemParamterDialog() }
    }

    fun toUploadLog() {
        LFilePicker()
            .withActivity(this)
            .withStartPath(LogFileUtils.CACHE_FILE_PATH) //指定初始显示路径
            .withIsGreater(true) //过滤文件大小 小于指定大小的文件
            .withFileSize(0) //指定文件大小为500K
            .withMutilyMode(false)
            .start()
    }


    fun showSystemParamterDialog() {
        if (null == systemDialog) {
            systemDialog = SystemParameterDialog(this@FunctionCenterActivity)
        }
        systemDialog!!.show()
    }
}