Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huangzhicong
/
SmartCanteen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
89869522
authored
Sep 09, 2019
by
patpat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化TimerHelper
parent
b4333db8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
app/src/main/java/com/bgycc/smartcanteen/helper/TimerHelper.kt
+10
-4
No files found.
app/src/main/java/com/bgycc/smartcanteen/helper/TimerHelper.kt
View file @
89869522
...
...
@@ -48,16 +48,22 @@ object TimerHelper {
}
fun
loop
(
task
:
LoopTask
,
period
:
Long
):
Long
{
return
loop
(
task
,
period
,
-
1
)
return
loop
(
task
,
period
,
-
1
,
0
)
}
fun
loop
(
task
:
LoopTask
,
period
:
Long
,
times
:
Int
):
Long
{
return
loop
({
id
:
Long
,
isLastTime
:
Boolean
->
task
.
run
(
id
,
isLastTime
)
},
period
,
times
)
},
period
,
times
,
0
)
}
fun
loop
(
runnable
:
(
id
:
Long
,
isLastTime
:
Boolean
)
->
Unit
,
period
:
Long
,
times
:
Int
=
-
1
):
Long
{
fun
loop
(
task
:
LoopTask
,
period
:
Long
,
times
:
Int
,
delay
:
Long
):
Long
{
return
loop
({
id
:
Long
,
isLastTime
:
Boolean
->
task
.
run
(
id
,
isLastTime
)
},
period
,
times
,
delay
)
}
fun
loop
(
runnable
:
(
id
:
Long
,
isLastTime
:
Boolean
)
->
Unit
,
period
:
Long
,
times
:
Int
=
-
1
,
delay
:
Long
=
0
):
Long
{
val
id
=
mId
mFutureList
.
put
(
id
,
mScheduledExecutorService
.
scheduleAtFixedRate
(
object
:
Runnable
{
var
vTimes
=
0
...
...
@@ -75,7 +81,7 @@ object TimerHelper {
Log
.
w
(
TAG
,
"loop id: $id times: $vTimes error: ${e.message}"
)
}
}
},
0
,
period
,
TimeUnit
.
MILLISECONDS
))
},
delay
,
period
,
TimeUnit
.
MILLISECONDS
))
return
id
}
...
...
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