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
52208a37
Commit
52208a37
authored
Apr 25, 2022
by
zhaopengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化本地关键数据存储
parent
0f9ad7f3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
8 deletions
+25
-8
LoginActivity.kt
app/src/main/java/com/miya/fastcashier/ui/LoginActivity.kt
+3
-0
MainActivity.kt
app/src/main/java/com/miya/fastcashier/ui/MainActivity.kt
+12
-2
DateUtils.java
app/src/main/java/com/miya/fastcashier/utils/DateUtils.java
+7
-0
LocalKeyDataMKManageKit.kt
.../miya/fastcashier/utils/manage/LocalKeyDataMKManageKit.kt
+3
-4
LoginViewModel.kt
...ain/java/com/miya/fastcashier/viewmodel/LoginViewModel.kt
+0
-2
No files found.
app/src/main/java/com/miya/fastcashier/ui/LoginActivity.kt
View file @
52208a37
...
@@ -18,6 +18,7 @@ import com.blankj.utilcode.util.ToastUtils
...
@@ -18,6 +18,7 @@ import com.blankj.utilcode.util.ToastUtils
import
com.miya.fastcashier.databinding.ActivityLoginBinding
import
com.miya.fastcashier.databinding.ActivityLoginBinding
import
com.miya.fastcashier.service.AccountService
import
com.miya.fastcashier.service.AccountService
import
com.miya.fastcashier.utils.clickWithTrigger
import
com.miya.fastcashier.utils.clickWithTrigger
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
...
@@ -71,6 +72,8 @@ class LoginActivity : AppCompatActivity() {
...
@@ -71,6 +72,8 @@ class LoginActivity : AppCompatActivity() {
AccountService
.
setUserName
(
username
.
text
.
toString
())
AccountService
.
setUserName
(
username
.
text
.
toString
())
AccountService
.
setAccountInfo
(
it1
)
AccountService
.
setAccountInfo
(
it1
)
//根据本地存储时间,MMKV初始化合理的结算时间
LocalKeyDataMKManageKit
.
handleCompliantBalanceDate
()
val
intent
=
Intent
()
val
intent
=
Intent
()
intent
.
setClass
(
this
@LoginActivity
,
MainActivity
::
class
.
java
)
intent
.
setClass
(
this
@LoginActivity
,
MainActivity
::
class
.
java
)
...
...
app/src/main/java/com/miya/fastcashier/ui/MainActivity.kt
View file @
52208a37
...
@@ -18,6 +18,7 @@ import com.miya.fastcashier.ui.dialog.CommonDialog
...
@@ -18,6 +18,7 @@ import com.miya.fastcashier.ui.dialog.CommonDialog
import
com.miya.fastcashier.ui.dialog.MessageDialog
import
com.miya.fastcashier.ui.dialog.MessageDialog
import
com.miya.fastcashier.utils.CenterToasty
import
com.miya.fastcashier.utils.CenterToasty
import
com.miya.fastcashier.utils.DateSelectHelper
import
com.miya.fastcashier.utils.DateSelectHelper
import
com.miya.fastcashier.utils.DateUtils
import
com.miya.fastcashier.utils.clickWithTrigger
import
com.miya.fastcashier.utils.clickWithTrigger
import
com.miya.fastcashier.utils.manage.AccountPasswordManageKit
import
com.miya.fastcashier.utils.manage.AccountPasswordManageKit
import
com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
import
com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
...
@@ -84,9 +85,14 @@ class MainActivity : BaseActivity() {
...
@@ -84,9 +85,14 @@ class MainActivity : BaseActivity() {
binding
.
llBalance
.
clickWithTrigger
{
binding
.
llBalance
.
clickWithTrigger
{
//上次记录的时间,或者当天0点
//上次记录的时间,或者当天0点
va
l
timeMillis
=
LocalKeyDataMKManageKit
.
getBalanceDate
()
va
r
timeMillis
=
LocalKeyDataMKManageKit
.
getBalanceDate
()
if
(
timeMillis
>
0L
&&
timeMillis
<=
System
.
currentTimeMillis
())
{
if
(
timeMillis
>
0L
&&
timeMillis
<=
System
.
currentTimeMillis
())
{
viewModel
.
orderStatistics
(
Date
(
timeMillis
),
Date
(),
true
)
val
currentDate
=
Date
()
var
daysAgoCurrent
:
Long
=
DateUtils
.
getDaysAgoCurrent
(
currentDate
,
3
)
if
(
timeMillis
<=
daysAgoCurrent
)
{
timeMillis
=
daysAgoCurrent
}
viewModel
.
orderStatistics
(
Date
(
timeMillis
),
currentDate
,
true
)
}
else
{
}
else
{
val
startDate
=
Calendar
.
getInstance
()
val
startDate
=
Calendar
.
getInstance
()
startDate
.
set
(
startDate
.
set
(
...
@@ -101,6 +107,10 @@ class MainActivity : BaseActivity() {
...
@@ -101,6 +107,10 @@ class MainActivity : BaseActivity() {
}
}
}
}
binding
.
tvStoreName
.
clickWithTrigger
{
LocalKeyDataMKManageKit
.
putBalanceDate
(
2
)
}
initData
()
initData
()
checkAccountPassword
()
checkAccountPassword
()
OrderRecordManageKit
.
clearOrderDataYeaterday
()
OrderRecordManageKit
.
clearOrderDataYeaterday
()
...
...
app/src/main/java/com/miya/fastcashier/utils/DateUtils.java
View file @
52208a37
...
@@ -166,6 +166,13 @@ public class DateUtils {
...
@@ -166,6 +166,13 @@ public class DateUtils {
return
calendar
.
getTime
().
getTime
();
return
calendar
.
getTime
().
getTime
();
}
}
/**
* 获取某天的n天以前的当前时间
*/
public
static
long
getDaysAgoCurrent
(
Date
date
,
int
daysAgoNum
)
{
return
date
.
getTime
()
-
daysAgoNum
*
24
*
3600
*
1000
;
}
/**
/**
* 得到前一天
* 得到前一天
*/
*/
...
...
app/src/main/java/com/miya/fastcashier/utils/manage/LocalKeyDataMKManageKit.kt
View file @
52208a37
...
@@ -41,7 +41,7 @@ class LocalKeyDataMKManageKit {
...
@@ -41,7 +41,7 @@ class LocalKeyDataMKManageKit {
* 结算时间合规化处理,适用于登录时
* 结算时间合规化处理,适用于登录时
* 策略:
* 策略:
* ①当获取的结算时间=0(证明本地未存储过,第一次登陆)存储为当前时间
* ①当获取的结算时间=0(证明本地未存储过,第一次登陆)存储为当前时间
* ②当获取的结算时间小于三天前的当前时间,则将结算时间重置为
两天前的零点
* ②当获取的结算时间小于三天前的当前时间,则将结算时间重置为
3天前的时间
*/
*/
fun
handleCompliantBalanceDate
()
{
fun
handleCompliantBalanceDate
()
{
LogUtils
.
e
(
BALANCEDATE_ID
,
"handleCompliantBalanceDate"
)
LogUtils
.
e
(
BALANCEDATE_ID
,
"handleCompliantBalanceDate"
)
...
@@ -54,9 +54,8 @@ class LocalKeyDataMKManageKit {
...
@@ -54,9 +54,8 @@ 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
){
val
daysAgoMillions
=
DateUtils
.
getDaysAgo
(
Date
(),
2
)
putBalanceDate
(
minimumTime
)
putBalanceDate
(
daysAgoMillions
)
LogUtils
.
e
(
BALANCEDATE_ID
,
"minimumTime:${DateUtils.format18(Date(minimumTime))}"
)
LogUtils
.
e
(
BALANCEDATE_ID
,
"daysAgoMillions:${DateUtils.format18(Date(daysAgoMillions))}"
)
}
}
}
}
...
...
app/src/main/java/com/miya/fastcashier/viewmodel/LoginViewModel.kt
View file @
52208a37
...
@@ -34,8 +34,6 @@ class LoginViewModel : ViewModel() {
...
@@ -34,8 +34,6 @@ class LoginViewModel : ViewModel() {
// LocalKeyDataMKManageKit.putBalanceDate(System.currentTimeMillis())
// LocalKeyDataMKManageKit.putBalanceDate(System.currentTimeMillis())
// }
// }
loginLiveData
.
postValue
(
result
)
loginLiveData
.
postValue
(
result
)
//根据本地存储时间,MMKV初始化合理的结算时间
LocalKeyDataMKManageKit
.
handleCompliantBalanceDate
()
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
loginLiveData
.
postValue
(
Result
.
failure
(
e
))
loginLiveData
.
postValue
(
Result
.
failure
(
e
))
}
}
...
...
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