Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
Widget
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Android Widget
Widget
Commits
c230942a
Commit
c230942a
authored
Sep 09, 2022
by
tongzifang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.2.0
parent
7e8082a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
3 deletions
+20
-3
build.gradle
zqtoolkit/build.gradle
+1
-1
ZqScaleKit.kt
...olkit/src/main/java/com/qmai/zqtoolkit/base/ZqScaleKit.kt
+0
-1
ScaleBaseKit.kt
...c/main/java/com/qmai/zqtoolkit/base/scale/ScaleBaseKit.kt
+19
-1
No files found.
zqtoolkit/build.gradle
View file @
c230942a
...
...
@@ -30,7 +30,7 @@ android {
}
}
group
'com.qmai.android.zqtoolkit'
version
'1.
1.8
'
version
'1.
2.0
'
gradlePublish
{
...
...
zqtoolkit/src/main/java/com/qmai/zqtoolkit/base/ZqScaleKit.kt
View file @
c230942a
...
...
@@ -28,7 +28,6 @@ object ZqScaleKit : ScaleBaseKit() {
get
()
=
4
override
val
SCALE_TYPE
:
QmScaleBrand
get
()
=
QmScaleBrand
.
ZQEB
private
var
connectCache
=
mutableListOf
<
Boolean
>()
override
fun
connect
(
cxt
:
Context
?,
scale
:
ScaleInfo
)
{
...
...
zqtoolkit/src/main/java/com/qmai/zqtoolkit/base/scale/ScaleBaseKit.kt
View file @
c230942a
...
...
@@ -4,6 +4,7 @@ import android.content.Context
import
com.qmai.zqtoolkit.ConnectState
import
com.qmai.zqtoolkit.LivingWeight
import
com.qmai.zqtoolkit.ScaleInfo
import
com.qmai.zqtoolkit.base.ZqScaleKit
import
com.qmai.zqtoolkit.config.QmScaleBrand
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.GlobalScope
...
...
@@ -32,6 +33,11 @@ abstract class ScaleBaseKit : ScaleBaseAction, ScaleUpdateAction {
private
var
stableWeight
=
mutableListOf
<
String
>()
var
connectCache
=
mutableListOf
<
Boolean
>()
private
val
readErrLimit
=
10
private
var
readErrCache
=
mutableListOf
<
Boolean
>()
override
fun
connect
(
cxt
:
Context
?,
scale
:
ScaleInfo
...
...
@@ -59,6 +65,7 @@ abstract class ScaleBaseKit : ScaleBaseAction, ScaleUpdateAction {
GlobalScope
.
launch
(
context
=
Dispatchers
.
IO
)
{
//稳定状态且读数正常
if
(
weight
.
isStable
&&
!
weight
.
isReadErr
)
{
readErrCache
.
clear
()
when
{
stableWeight
.
size
==
STABLE_COUNT
->
{
if
(
stableWeight
.
toSet
().
size
==
1
)
{
...
...
@@ -74,7 +81,18 @@ abstract class ScaleBaseKit : ScaleBaseAction, ScaleUpdateAction {
}
else
->
stableWeight
.
add
(
weight
.
weight
)
}
}
else
_livingWeight
.
emit
(
weight
)
}
else
{
_livingWeight
.
emit
(
weight
)
if
(
weight
.
isReadErr
)
when
{
readErrCache
.
size
>=
readErrLimit
->
{
if
(
readErrCache
.
toSet
().
size
==
1
)
disconnect
()
connectCache
.
clear
()
}
else
->
readErrCache
.
add
(
true
)
}
}
}
}
...
...
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