Commit 1e6b3443 authored by 赵鹏翔's avatar 赵鹏翔

整理main

parent 70f77d93
......@@ -20,7 +20,6 @@ import com.miya.fastcashier.databinding.ActivityLoginBinding
import com.miya.fastcashier.util.manage.LocalKeyDataMKManageKit
import com.miya.fastcashier.viewmodel.LoginViewModel
import com.permissionx.guolindev.PermissionX
import com.permissionx.guolindev.callback.RequestCallback
class LoginActivity : AppCompatActivity() {
......
......@@ -45,6 +45,13 @@ class MainActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initView()
initData()
initListener()
}
private fun initView() {
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
viewModel = ViewModelProvider(this).get(MainViewModel::class.java)
......@@ -52,7 +59,34 @@ class MainActivity : BaseActivity() {
binding.tvStoreName.text = AccountService.getAccountInfo()?.shopInfo?.storeName
binding.tvSlog.text = AccountService.getUserName()
binding.tvVersion.text = getVersionName(this)
}
private fun initData() {
viewModel.statisticsLiveData.observe(this, { result ->
result.onSuccess {
}
result.onFailure { e ->
CenterToasty.error(this@MainActivity, e.message ?: "").show()
}
})
viewModel.balanceLiveData.observe(this, { result ->
result.onSuccess {
LocalKeyDataMKManageKit.putBalanceDate(it)
}
result.onFailure { e ->
CenterToasty.error(this@MainActivity, e.message ?: "").show()
}
})
checkAccountPassword()
OrderRecordManageKit.clearOrderDataYeaterday()
LogFileUtils.deleteLog(LogFileUtils.DAYS_INTERVAL_LOG_DELETE)
PayLogFileUtils.deleteLog(LogFileUtils.DAYS_INTERVAL_LOG_DELETE)
}
private fun initListener() {
binding.llPay.clickWithTrigger {
PriceInputActivity.start(this@MainActivity)
}
......@@ -79,8 +113,9 @@ class MainActivity : BaseActivity() {
dateSelectHelper = DateSelectHelper(this@MainActivity) {
var currentDate = Date()
if (currentDate.time <= it.time){
CenterToasty.error(this@MainActivity,getString(R.string.toast_warn_time)).show()
if (currentDate.time <= it.time) {
CenterToasty.error(this@MainActivity, getString(R.string.toast_warn_time))
.show()
return@DateSelectHelper
}
viewModel.orderStatistics(it, currentDate, false)
......@@ -91,12 +126,10 @@ class MainActivity : BaseActivity() {
binding.llBalance.clickWithTrigger {
showConfirmBalanceDialog()
}
}
initData()
checkAccountPassword()
OrderRecordManageKit.clearOrderDataYeaterday()
LogFileUtils.deleteLog(LogFileUtils.DAYS_INTERVAL_LOG_DELETE)
PayLogFileUtils.deleteLog(LogFileUtils.DAYS_INTERVAL_LOG_DELETE)
private fun checkAccountPassword() {
AccountPasswordManageKit.get().checkAccountPassword(this)
}
private fun toRefund() {
......@@ -109,30 +142,6 @@ class MainActivity : BaseActivity() {
AuthorizePasswordInputDialog.newInstance().show(fm, FRAGMENT_TAG)
}
private fun checkAccountPassword() {
AccountPasswordManageKit.get().checkAccountPassword(this)
}
private fun initData() {
viewModel.statisticsLiveData.observe(this, { result ->
result.onSuccess {
}
result.onFailure { e ->
CenterToasty.error(this@MainActivity, e.message ?: "").show()
}
})
viewModel.balanceLiveData.observe(this, { result ->
result.onSuccess {
LocalKeyDataMKManageKit.putBalanceDate(it)
}
result.onFailure { e ->
CenterToasty.error(this@MainActivity, e.message ?: "").show()
}
})
}
private fun showConfirmBalanceDialog() {
if (confirmDialog == null || !confirmDialog!!.isShowing) {
confirmDialog = CommonDialog(this)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment