Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MiYaFastCashier
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangjiantao
MiYaFastCashier
Commits
928e7aa5
Commit
928e7aa5
authored
Apr 27, 2022
by
zhaopengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
存储数据优化
parent
0bb3cb46
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
23 deletions
+66
-23
BaseApplication.kt
app/src/main/java/com/miya/fastcashier/BaseApplication.kt
+2
-1
AccountService.kt
.../main/java/com/miya/fastcashier/service/AccountService.kt
+6
-1
LoginActivity.kt
app/src/main/java/com/miya/fastcashier/ui/LoginActivity.kt
+13
-18
MainActivity.kt
app/src/main/java/com/miya/fastcashier/ui/MainActivity.kt
+10
-0
LocalKeyDataMKManageKit.kt
.../miya/fastcashier/utils/manage/LocalKeyDataMKManageKit.kt
+35
-3
No files found.
app/src/main/java/com/miya/fastcashier/BaseApplication.kt
View file @
928e7aa5
...
@@ -18,6 +18,7 @@ import com.miya.fastcashier.utils.ContextUtils
...
@@ -18,6 +18,7 @@ import com.miya.fastcashier.utils.ContextUtils
import
com.miya.fastcashier.utils.DateUtils
import
com.miya.fastcashier.utils.DateUtils
import
com.miya.fastcashier.utils.DensityUtils
import
com.miya.fastcashier.utils.DensityUtils
import
com.miya.fastcashier.utils.LogFileUtils
import
com.miya.fastcashier.utils.LogFileUtils
import
com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
import
com.miya.fastcashier.utils.manage.OrderRecordManageKit
import
com.miya.fastcashier.utils.manage.OrderRecordManageKit
import
com.miya.print.PrinterManager
import
com.miya.print.PrinterManager
import
com.sdy.miya.moblie.component.pay.core.net.MiYaPayMobileApiClient
import
com.sdy.miya.moblie.component.pay.core.net.MiYaPayMobileApiClient
...
@@ -144,7 +145,7 @@ class BaseApplication : MultiDexApplication() {
...
@@ -144,7 +145,7 @@ class BaseApplication : MultiDexApplication() {
}
}
fun
resetConfig
()
{
fun
resetConfig
()
{
MMKV
.
defaultMMKV
().
clearAll
()
LocalKeyDataMKManageKit
.
clearCommonData
()
//清除本地订单昨天的流水信息
//清除本地订单昨天的流水信息
OrderRecordManageKit
.
clearOrderDataYeaterday
()
OrderRecordManageKit
.
clearOrderDataYeaterday
()
//清除本地个人信息
//清除本地个人信息
...
...
app/src/main/java/com/miya/fastcashier/service/AccountService.kt
View file @
928e7aa5
...
@@ -33,9 +33,14 @@ object AccountService {
...
@@ -33,9 +33,14 @@ object AccountService {
this
.
accountPassword
=
accountPassword
this
.
accountPassword
=
accountPassword
}
}
fun
clear
(){
fun
clear
()
{
selfCashierAccountInfo
=
null
selfCashierAccountInfo
=
null
userName
=
""
userName
=
""
accountPassword
=
""
accountPassword
=
""
}
}
fun
init
(
selfCashierAccountInfo
:
SelfCashierAccountInfo
?,
userName
:
String
)
{
this
.
selfCashierAccountInfo
=
selfCashierAccountInfo
this
.
userName
=
userName
}
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/ui/LoginActivity.kt
View file @
928e7aa5
...
@@ -21,7 +21,6 @@ import com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
...
@@ -21,7 +21,6 @@ import com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
import
com.miya.fastcashier.viewmodel.LoginViewModel
import
com.miya.fastcashier.viewmodel.LoginViewModel
import
com.permissionx.guolindev.PermissionX
import
com.permissionx.guolindev.PermissionX
import
com.permissionx.guolindev.callback.RequestCallback
import
com.permissionx.guolindev.callback.RequestCallback
import
com.tencent.mmkv.MMKV
class
LoginActivity
:
AppCompatActivity
()
{
class
LoginActivity
:
AppCompatActivity
()
{
...
@@ -29,7 +28,7 @@ class LoginActivity : AppCompatActivity() {
...
@@ -29,7 +28,7 @@ class LoginActivity : AppCompatActivity() {
private
lateinit
var
loginViewModel
:
LoginViewModel
private
lateinit
var
loginViewModel
:
LoginViewModel
private
lateinit
var
binding
:
ActivityLoginBinding
private
lateinit
var
binding
:
ActivityLoginBinding
companion
object
{
companion
object
{
fun
start
(
context
:
Context
,
flags
:
Int
)
{
fun
start
(
context
:
Context
,
flags
:
Int
)
{
val
intent
=
Intent
(
context
,
LoginActivity
::
class
.
java
)
val
intent
=
Intent
(
context
,
LoginActivity
::
class
.
java
)
intent
.
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
or
flags
intent
.
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
or
flags
...
@@ -48,8 +47,6 @@ class LoginActivity : AppCompatActivity() {
...
@@ -48,8 +47,6 @@ class LoginActivity : AppCompatActivity() {
val
login
=
binding
.
login
val
login
=
binding
.
login
val
tvErrInfo
=
binding
.
tvErrInfo
val
tvErrInfo
=
binding
.
tvErrInfo
val
kv
=
MMKV
.
defaultMMKV
()
loginViewModel
=
ViewModelProvider
(
this
)
loginViewModel
=
ViewModelProvider
(
this
)
.
get
(
LoginViewModel
::
class
.
java
)
.
get
(
LoginViewModel
::
class
.
java
)
...
@@ -66,18 +63,15 @@ class LoginActivity : AppCompatActivity() {
...
@@ -66,18 +63,15 @@ class LoginActivity : AppCompatActivity() {
result
.
getOrNull
().
also
{
result
.
getOrNull
().
also
{
it
?.
let
{
it1
->
it
?.
let
{
it1
->
kv
.
encode
(
"username"
,
username
.
text
.
toString
()
)
val
userName
=
username
.
text
.
toString
(
)
kv
.
encode
(
"password"
,
password
.
text
.
toString
()
)
val
passWord
=
password
.
text
.
toString
(
)
AccountService
.
setUserName
(
username
.
text
.
toString
()
)
LocalKeyDataMKManageKit
.
putLoginIngfo
(
userName
,
passWord
)
AccountService
.
setAccountInfo
(
it1
)
AccountService
.
init
(
it1
,
userName
)
//根据本地存储时间,MMKV初始化合理的结算时间
//根据本地存储时间,MMKV初始化合理的结算时间
LocalKeyDataMKManageKit
.
handleCompliantBalanceDate
()
LocalKeyDataMKManageKit
.
handleCompliantBalanceDate
()
val
intent
=
Intent
()
MainActivity
.
start
(
this
@LoginActivity
)
intent
.
setClass
(
this
@LoginActivity
,
MainActivity
::
class
.
java
)
startActivity
(
intent
)
finish
()
finish
()
}
}
}
}
...
@@ -140,18 +134,19 @@ class LoginActivity : AppCompatActivity() {
...
@@ -140,18 +134,19 @@ class LoginActivity : AppCompatActivity() {
}
}
}
}
kv
.
decodeString
(
"username"
)
?.
let
{
LocalKeyDataMKManageKit
.
getLoginUserName
(
)
?.
let
{
username
.
setText
(
it
)
username
.
setText
(
it
)
}
}
kv
.
decodeString
(
"password"
)
?.
let
{
LocalKeyDataMKManageKit
.
getLoginUserPassword
(
)
?.
let
{
password
.
setText
(
it
)
password
.
setText
(
it
)
}
}
if
(!
TextUtils
.
isEmpty
(
username
.
text
)
if
(!
TextUtils
.
isEmpty
(
username
.
text
)
&&
!
TextUtils
.
isEmpty
(
password
.
text
))
{
&&
!
TextUtils
.
isEmpty
(
password
.
text
)
)
{
loading
.
visibility
=
View
.
VISIBLE
;
loading
.
visibility
=
View
.
VISIBLE
;
loginViewModel
.
login
(
username
.
text
.
toString
(),
password
.
text
.
toString
())
loginViewModel
.
login
(
username
.
text
.
toString
(),
password
.
text
.
toString
()
)
}
}
}
}
...
...
app/src/main/java/com/miya/fastcashier/ui/MainActivity.kt
View file @
928e7aa5
package
com.miya.fastcashier.ui
package
com.miya.fastcashier.ui
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.os.Bundle
import
android.os.Bundle
import
android.widget.Toast
import
android.widget.Toast
...
@@ -26,6 +27,15 @@ class MainActivity : BaseActivity() {
...
@@ -26,6 +27,15 @@ class MainActivity : BaseActivity() {
private
lateinit
var
viewModel
:
MainViewModel
private
lateinit
var
viewModel
:
MainViewModel
private
var
dateSelectHelper
:
DateSelectHelper
?
=
null
private
var
dateSelectHelper
:
DateSelectHelper
?
=
null
companion
object
{
@JvmStatic
fun
start
(
context
:
Context
)
{
val
intent
=
Intent
()
intent
.
setClass
(
context
,
MainActivity
::
class
.
java
)
context
.
startActivity
(
intent
)
}
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
binding
=
ActivityMainBinding
.
inflate
(
layoutInflater
)
binding
=
ActivityMainBinding
.
inflate
(
layoutInflater
)
...
...
app/src/main/java/com/miya/fastcashier/utils/manage/LocalKeyDataMKManageKit.kt
View file @
928e7aa5
...
@@ -18,6 +18,7 @@ class LocalKeyDataMKManageKit {
...
@@ -18,6 +18,7 @@ class LocalKeyDataMKManageKit {
companion
object
{
companion
object
{
/***************************************** 分账户的关键数据,分区存储ID为MMKV_ID *****************************************/
private
val
MMKV_ID
=
"fastcashier_key_data"
private
val
MMKV_ID
=
"fastcashier_key_data"
private
val
BALANCEDATE_ID
=
"balanceDate"
private
val
BALANCEDATE_ID
=
"balanceDate"
...
@@ -53,16 +54,16 @@ class LocalKeyDataMKManageKit {
...
@@ -53,16 +54,16 @@ class LocalKeyDataMKManageKit {
}
}
var
minimumTime
:
Long
=
System
.
currentTimeMillis
()
-
3
*
24
*
3600
*
1000
var
minimumTime
:
Long
=
System
.
currentTimeMillis
()
-
3
*
24
*
3600
*
1000
if
(
balanceTime
<=
minimumTime
){
if
(
balanceTime
<=
minimumTime
)
{
putBalanceDate
(
minimumTime
)
putBalanceDate
(
minimumTime
)
LogUtils
.
e
(
BALANCEDATE_ID
,
"minimumTime:${DateUtils.format18(Date(minimumTime))}"
)
LogUtils
.
e
(
BALANCEDATE_ID
,
"minimumTime:${DateUtils.format18(Date(minimumTime))}"
)
}
}
}
}
/**
/**
* 清除关键数据
* 清除关键数据
的mmkv存储
*/
*/
fun
clear
()
{
fun
clear
KeyData
()
{
getKeyDataMK
().
clearAll
()
getKeyDataMK
().
clearAll
()
}
}
...
@@ -70,5 +71,36 @@ class LocalKeyDataMKManageKit {
...
@@ -70,5 +71,36 @@ class LocalKeyDataMKManageKit {
val
MMKV_ID_WITH_USER
=
MMKV_ID
.
plus
(
"_${AccountService.getUserName()}"
)
val
MMKV_ID_WITH_USER
=
MMKV_ID
.
plus
(
"_${AccountService.getUserName()}"
)
return
MMKV
.
mmkvWithID
(
MMKV_ID_WITH_USER
)
return
MMKV
.
mmkvWithID
(
MMKV_ID_WITH_USER
)
}
}
/***************************************** 普通存储的关键数据,分区存储ID为默认 *****************************************/
private
val
USERNAME_ID
=
"username"
private
val
USERPASSWORD_ID
=
"password"
/**
* 存储登录信息:姓名、密码
*/
fun
putLoginIngfo
(
userName
:
String
,
password
:
String
)
{
MMKV
.
defaultMMKV
().
encode
(
USERNAME_ID
,
userName
)
MMKV
.
defaultMMKV
().
encode
(
USERPASSWORD_ID
,
password
)
}
/**
* 获取登录姓名
*/
fun
getLoginUserName
():
String
?
{
return
MMKV
.
defaultMMKV
().
decodeString
(
USERNAME_ID
)
}
/**
* 获取登录密码
*/
fun
getLoginUserPassword
():
String
?
{
return
MMKV
.
defaultMMKV
().
decodeString
(
USERPASSWORD_ID
)
}
fun
clearCommonData
()
{
MMKV
.
defaultMMKV
().
clearAll
()
}
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment