Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
A
AnchorCollect
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hywang
AnchorCollect
Commits
603c57d4
Commit
603c57d4
authored
Jun 14, 2023
by
hywang
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
beed5e0a
2cda0f48
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
9 deletions
+51
-9
build.gradle
app/build.gradle
+2
-2
BtService.java
app/src/main/java/com/phlx/anchorcollect/bt/BtService.java
+11
-1
LoginActivity.java
...n/java/com/phlx/anchorcollect/ui/login/LoginActivity.java
+16
-0
LoginVM.java
...rc/main/java/com/phlx/anchorcollect/ui/login/LoginVM.java
+8
-0
DateUtils.java
app/src/main/java/com/phlx/anchorcollect/util/DateUtils.java
+14
-6
No files found.
app/build.gradle
View file @
603c57d4
...
...
@@ -9,8 +9,8 @@ android {
applicationId
"com.phlx.anchorcollect"
minSdkVersion
21
targetSdkVersion
29
versionCode
6
versionName
"
1.0.5
"
versionCode
7
versionName
"
2.0.1
"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
...
...
app/src/main/java/com/phlx/anchorcollect/bt/BtService.java
View file @
603c57d4
...
...
@@ -23,6 +23,7 @@ import cn.wandersnail.bluetooth.Connection;
import
cn.wandersnail.bluetooth.EventObserver
;
import
cn.wandersnail.commons.util.ToastUtils
;
import
me.goldze.mvvmhabit.bus.RxBus
;
import
me.goldze.mvvmhabit.utils.StringUtils
;
public
class
BtService
extends
Service
implements
EventObserver
{
...
...
@@ -72,7 +73,16 @@ public class BtService extends Service implements EventObserver {
// Log.e(TAG, "onRead: " + data);
// ToastUtils.showShort("onRead: " + data);
String
weightData
=
data
.
substring
(
data
.
indexOf
(
"wn"
)
+
3
,
data
.
indexOf
(
"kg"
));
String
weightData
=
data
.
substring
(
data
.
indexOf
(
"wn"
)
+
3
,
data
.
indexOf
(
"kg"
)).
trim
();
if
(
StringUtils
.
isEmpty
(
weightData
))
{
//如果是空数据,返回-1
weightData
=
"-1"
;
// return;
}
try
{
//判断数据是否合法,不合法返回-100
Double
.
parseDouble
(
weightData
);
}
catch
(
Exception
e
)
{
weightData
=
"-100"
;
}
EventMsg
eventMsg
=
new
EventMsg
();
eventMsg
.
setAction
(
Configs
.
currentEvent
);
eventMsg
.
setObj
(
weightData
);
...
...
app/src/main/java/com/phlx/anchorcollect/ui/login/LoginActivity.java
View file @
603c57d4
...
...
@@ -99,6 +99,22 @@ public class LoginActivity extends BaseActivity<ActivityLoginBinding, LoginVM> {
}
}
});
viewModel
.
dateEvent
.
observe
(
this
,
new
Observer
<
Integer
>()
{
@Override
public
void
onChanged
(
Integer
integer
)
{
new
MaterialDialog
.
Builder
(
LoginActivity
.
this
).
canceledOnTouchOutside
(
false
).
title
(
"系统提示"
).
content
(
"日期错误,请联网自动获取日期"
).
positiveText
(
"退出"
).
onAny
(
new
MaterialDialog
.
SingleButtonCallback
()
{
@Override
public
void
onClick
(
@NonNull
MaterialDialog
dialog
,
@NonNull
DialogAction
which
)
{
if
(
which
==
DialogAction
.
POSITIVE
)
{
ModuleManager
.
destroyLibSO
();
finish
();
android
.
os
.
Process
.
killProcess
(
android
.
os
.
Process
.
myPid
());
}
}
}).
show
();
}
});
}
@Override
...
...
app/src/main/java/com/phlx/anchorcollect/ui/login/LoginVM.java
View file @
603c57d4
...
...
@@ -25,6 +25,7 @@ import com.phlx.anchorcollect.params.BaseResponse;
import
com.phlx.anchorcollect.params.CollectResponse
;
import
com.phlx.anchorcollect.ui.main.MainActivity
;
import
com.phlx.anchorcollect.ui.splash.SplashActivity
;
import
com.phlx.anchorcollect.util.DateUtils
;
import
com.phlx.anchorcollect.util.StringUtil
;
import
com.phlx.anchorcollect.util.TextUtil
;
...
...
@@ -63,6 +64,9 @@ public class LoginVM extends BaseViewModel<Repository> {
//更新app
public
SingleLiveEvent
<
Integer
>
appUpdateEvent
=
new
SingleLiveEvent
<>();
//手机时间问题,退出软件
public
SingleLiveEvent
<
Integer
>
dateEvent
=
new
SingleLiveEvent
<>();
public
int
loginType
;
//登录后是否跳转, 0跳转main 1不跳转
...
...
@@ -109,6 +113,10 @@ public class LoginVM extends BaseViewModel<Repository> {
public
BindingCommand
loginOnClickCommand
=
new
BindingCommand
(
new
BindingAction
()
{
@Override
public
void
call
()
{
if
(
Integer
.
parseInt
(
DateUtils
.
getYear
())<
2020
){
dateEvent
.
call
();
return
;
}
if
(
Configs
.
isOnLine
)
{
login
();
}
else
{
...
...
app/src/main/java/com/phlx/anchorcollect/util/DateUtils.java
View file @
603c57d4
package
com
.
phlx
.
anchorcollect
.
util
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
public
class
DateUtils
{
public
static
String
getYear
()
{
public
static
String
getYear
()
{
String
year
=
""
;
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy"
);
year
=
simpleDateFormat
.
format
(
new
Date
());
return
year
;
}
}
public
static
long
getYearLong
()
{
Calendar
c1
=
Calendar
.
getInstance
();
c1
.
set
(
Integer
.
parseInt
(
getYear
()),
0
,
1
,
0
,
0
,
0
);
return
c1
.
getTimeInMillis
();
}
}
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