Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StatInfo_1
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
chenyuling
StatInfo_1
Commits
8b53b469
Commit
8b53b469
authored
Sep 28, 2023
by
chenyuling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"优化连接接口状态存储"
parent
f3847fe2
Pipeline
#1634
canceled with stages
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
6 deletions
+20
-6
MainActivity.java
...rc/main/java/com/srthinker/statinfo/uis/MainActivity.java
+5
-2
MyApplication.java
...c/main/java/com/srthinker/statinfo/uis/MyApplication.java
+4
-0
SettingActivity.java
...java/com/srthinker/statinfo/uis/news/SettingActivity.java
+11
-4
No files found.
app/src/main/java/com/srthinker/statinfo/uis/MainActivity.java
View file @
8b53b469
...
...
@@ -213,10 +213,13 @@ public class MainActivity extends BaseActivity implements NetworkIPMonitor.OnIPC
@Override
public
void
onAllConnectStatus
(
boolean
hasConnect
,
int
type
)
{
HashMap
<
String
,
Boolean
>
devicesConnect
=
MyApplication
.
getInstance
().
devicesConnect
;
if
(
type
==
ENTER_TYPE
){
SharedUtil
.
getInstance
(
this
).
writeShared
(
"enter_connect"
,
hasConnect
);
devicesConnect
.
put
(
"enter_connect"
,
hasConnect
);
// SharedUtil.getInstance(this).writeShared("enter_connect",hasConnect);
}
else
if
(
type
==
LEAVE_TYPE
){
SharedUtil
.
getInstance
(
this
).
writeShared
(
"leave_connect"
,
hasConnect
);
// SharedUtil.getInstance(this).writeShared("leave_connect",hasConnect);
devicesConnect
.
put
(
"leave_connect"
,
hasConnect
);
}
}
...
...
app/src/main/java/com/srthinker/statinfo/uis/MyApplication.java
View file @
8b53b469
...
...
@@ -4,8 +4,12 @@ import android.app.Application;
import
com.raizlabs.android.dbflow.config.FlowManager
;
import
java.util.HashMap
;
public
class
MyApplication
extends
Application
{
private
static
MyApplication
application
;
//声明一个公共的变量,存储网络状态
public
HashMap
<
String
,
Boolean
>
devicesConnect
=
new
HashMap
<>();
// 1秒钟后重启应用
private
int
time
=
1000
;
...
...
app/src/main/java/com/srthinker/statinfo/uis/news/SettingActivity.java
View file @
8b53b469
...
...
@@ -33,6 +33,7 @@ import com.srthinker.statinfo.presenter.ApiQuest;
import
com.srthinker.statinfo.presenter.StatSize
;
import
com.srthinker.statinfo.uis.BaseActivity
;
import
com.srthinker.statinfo.uis.GroupActivity
;
import
com.srthinker.statinfo.uis.MyApplication
;
import
com.srthinker.statinfo.uis.fragment.ConfigDlgFragment
;
import
com.srthinker.statinfo.util.common.ClickUtil
;
import
com.srthinker.statinfo.util.common.SharedUtil
;
...
...
@@ -145,8 +146,11 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que
}
private
void
updateDeviceConnect
()
{
enter_connect
=
SharedUtil
.
getInstance
(
this
).
readShared
(
"enter_connect"
,
false
);
leave_connect
=
SharedUtil
.
getInstance
(
this
).
readShared
(
"leave_connect"
,
false
);
HashMap
<
String
,
Boolean
>
devicesConnect
=
MyApplication
.
getInstance
().
devicesConnect
;
enter_connect
=
devicesConnect
.
getOrDefault
(
"enter_connect"
,
false
);
leave_connect
=
devicesConnect
.
getOrDefault
(
"leave_connect"
,
false
);
/*enter_connect = SharedUtil.getInstance(this).readShared("enter_connect", false);
leave_connect = SharedUtil.getInstance(this).readShared("leave_connect", false);*/
if
(
enter_connect
){
mBinding
.
tvEnterError
.
setVisibility
(
View
.
GONE
);
}
else
{
...
...
@@ -450,8 +454,10 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que
Log
.
i
(
TAG
,
"onAllConnectStatus: 接收到的连接状态 hasConnect="
+
hasConnect
);
Log
.
i
(
TAG
,
"onAllConnectStatus: type="
+
type
);
runOnUiThread
(()->{
HashMap
<
String
,
Boolean
>
devicesConnect
=
MyApplication
.
getInstance
().
devicesConnect
;
if
(
type
==
ENTER_TYPE
){
SharedUtil
.
getInstance
(
this
).
writeShared
(
"enter_connect"
,
hasConnect
);
devicesConnect
.
put
(
"enter_connect"
,
hasConnect
);
//SharedUtil.getInstance(this).writeShared("enter_connect",hasConnect);
if
(!
hasConnect
)
{
mBinding
.
tvEnterError
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
...
...
@@ -459,7 +465,8 @@ public class SettingActivity extends BaseActivity implements ConfigCallback, Que
}
}
else
if
(
type
==
LEAVE_TYPE
){
SharedUtil
.
getInstance
(
this
).
writeShared
(
"leave_connect"
,
hasConnect
);
devicesConnect
.
put
(
"leave_connect"
,
hasConnect
);
//SharedUtil.getInstance(this).writeShared("leave_connect",hasConnect);
if
(!
hasConnect
)
{
mBinding
.
tvLeaveError
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
...
...
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