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
66bbc4e8
Commit
66bbc4e8
authored
Jun 08, 2022
by
赵鹏翔
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化时间选择器逻辑
parent
0b414329
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
24 deletions
+31
-24
MainActivity.kt
app/src/main/java/com/miya/fastcashier/ui/MainActivity.kt
+12
-5
DateSelectHelper.kt
.../main/java/com/miya/fastcashier/utils/DateSelectHelper.kt
+17
-19
strings.xml
app/src/main/res/values/strings.xml
+2
-0
No files found.
app/src/main/java/com/miya/fastcashier/ui/MainActivity.kt
View file @
66bbc4e8
...
...
@@ -2,6 +2,7 @@ package com.miya.fastcashier.ui
import
android.content.Intent
import
android.os.Bundle
import
android.util.Log
import
android.view.Gravity
import
android.widget.Toast
import
androidx.appcompat.app.AppCompatActivity
...
...
@@ -21,6 +22,7 @@ import com.miya.fastcashier.utils.*
import
com.miya.fastcashier.utils.manage.AccountPasswordManageKit
import
com.miya.fastcashier.utils.manage.LocalKeyDataMKManageKit
import
com.miya.fastcashier.viewmodel.MainViewModel
import
es.dmoral.toasty.Toasty
import
java.util.*
class
MainActivity
:
BaseActivity
()
{
...
...
@@ -78,10 +80,15 @@ class MainActivity : BaseActivity() {
}
binding
.
llStatistic
.
clickWithTrigger
{
if
(
dateSelectHelper
==
null
)
{
dateSelectHelper
=
DateSelectHelper
(
this
@MainActivity
)
{
viewModel
.
orderStatistics
(
it
,
Date
(),
false
)
dateSelectHelper
=
DateSelectHelper
(
this
@MainActivity
)
{
var
currentDate
=
Date
()
if
(
currentDate
.
time
<=
it
.
time
){
CenterToasty
.
error
(
this
@MainActivity
,
getString
(
R
.
string
.
toast_warn_time
)).
show
()
return
@DateSelectHelper
}
viewModel
.
orderStatistics
(
it
,
currentDate
,
false
)
}
dateSelectHelper
!!
.
showDatePicker
()
}
...
...
@@ -130,7 +137,7 @@ class MainActivity : BaseActivity() {
})
}
private
fun
showConfirmBalanceDialog
(){
private
fun
showConfirmBalanceDialog
()
{
if
(
confirmDialog
==
null
||
!
confirmDialog
!!
.
isShowing
)
{
confirmDialog
=
CommonDialog
(
this
)
confirmDialog
!!
.
setCustomMessage
(
getString
(
R
.
string
.
app_text_confirm_balance
))
...
...
@@ -153,7 +160,7 @@ class MainActivity : BaseActivity() {
}
}
private
fun
toBalance
(){
private
fun
toBalance
()
{
//上次记录的时间,或者当天0点
var
timeMillis
=
LocalKeyDataMKManageKit
.
getBalanceDate
()
if
(
timeMillis
>
0L
&&
timeMillis
<=
System
.
currentTimeMillis
())
{
...
...
app/src/main/java/com/miya/fastcashier/utils/DateSelectHelper.kt
View file @
66bbc4e8
...
...
@@ -15,21 +15,6 @@ import java.util.*
class
DateSelectHelper
(
val
act
:
Activity
,
val
callback
:
(
Date
)
->
Unit
)
{
var
timePickerView
:
TimePickerView
?
=
null
fun
showDatePicker
()
{
if
(
timePickerView
==
null
)
{
initTimePicker
()
}
val
date
=
Calendar
.
getInstance
()
date
.
set
(
date
.
get
(
Calendar
.
YEAR
),
date
.
get
(
Calendar
.
MONTH
),
date
.
get
(
Calendar
.
DAY_OF_MONTH
),
0
,
0
)
timePickerView
!!
.
setDate
(
date
)
timePickerView
!!
.
show
()
}
private
fun
initTimePicker
()
{
val
calendar
=
Calendar
.
getInstance
()
...
...
@@ -51,9 +36,9 @@ class DateSelectHelper(val act: Activity, val callback: (Date) -> Unit) {
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
),
calendar
.
get
(
Calendar
.
MINUTE
)
)
timePickerView
=
TimePickerBuilder
(
act
,
OnTimeSelectListener
{
date
,
v
->
timePickerView
=
TimePickerBuilder
(
act
)
{
date
,
v
->
callback
(
date
)
}
)
}
.
setTitleText
(
"请选择开始时间"
)
.
setType
(
booleanArrayOf
(
false
,
false
,
false
,
true
,
true
,
false
))
.
setDate
(
startDate
)
...
...
@@ -67,9 +52,22 @@ class DateSelectHelper(val act: Activity, val callback: (Date) -> Unit) {
.
build
()
}
fun
showDatePicker
()
{
timePickerView
=
null
initTimePicker
()
val
date
=
Calendar
.
getInstance
()
date
.
set
(
date
.
get
(
Calendar
.
YEAR
),
date
.
get
(
Calendar
.
MONTH
),
date
.
get
(
Calendar
.
DAY_OF_MONTH
),
0
,
0
)
timePickerView
!!
.
setDate
(
date
)
timePickerView
!!
.
show
()
}
fun
dismiss
()
{
timePickerView
?.
dismiss
()
}
}
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
66bbc4e8
...
...
@@ -38,6 +38,8 @@
<string
name=
"app_confirm"
>
确认
</string>
<string
name=
"app_unkown"
>
未知
</string>
<string
name=
"toast_click_again"
>
再点击%1$d次进入身份验证
</string>
<string
name=
"toast_warn_time"
>
开始时间不能大于结束时间!
</string>
<!--日志上传字段-->
<string
name=
"lfile_Cancel"
>
取消全选
</string>
...
...
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