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
a768d877
authored
Nov 19, 2019
by
patpat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
禁用网络切换功能
parent
d1924aa9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
+13
-12
app/src/main/java/com/bgycc/smartcanteen/manager/NetworkManager.kt
+6
-5
app/src/main/java/com/bgycc/smartcanteen/server/websocket/MainWebSocket.java
+7
-7
No files found.
app/src/main/java/com/bgycc/smartcanteen/manager/NetworkManager.kt
View file @
a768d877
...
...
@@ -14,11 +14,12 @@ object NetworkManager {
val
currentTypeString
:
String
get
()
{
return
when
(
mTransportType
)
{
NetworkCapabilities
.
TRANSPORT_ETHERNET
->
"以太网"
NetworkCapabilities
.
TRANSPORT_WIFI
->
"Wifi"
else
->
"未知"
}
return
""
// return when (mTransportType) {
// NetworkCapabilities.TRANSPORT_ETHERNET -> "以太网"
// NetworkCapabilities.TRANSPORT_WIFI -> "Wifi"
// else -> "未知"
// }
}
private
var
mConnectivityManager
:
ConnectivityManager
?
=
null
...
...
app/src/main/java/com/bgycc/smartcanteen/server/websocket/MainWebSocket.java
View file @
a768d877
...
...
@@ -62,15 +62,15 @@ public class MainWebSocket extends WebSocketClient {
@Override
public
void
run
(
long
id
,
boolean
isLastTime
)
{
if
(
sInstance
.
isClosed
())
{
if
(
sReconnectTimes
<
3
)
{
sReconnectTimes
++;
//
if (sReconnectTimes < 3) {
//
sReconnectTimes++;
sInstance
.
reconnect
();
EventBus
.
getDefault
().
post
(
new
ConnectStateEvent
(
ConnectStateEvent
.
RECONNECTING
));
}
else
{
sReconnectTimes
=
0
;
NetworkManager
.
INSTANCE
.
switchNetwork
();
EventBus
.
getDefault
().
post
(
new
ConnectStateEvent
(
ConnectStateEvent
.
CHANGE_NETWORK
));
}
//
} else {
//
sReconnectTimes = 0;
//
NetworkManager.INSTANCE.switchNetwork();
//
EventBus.getDefault().post(new ConnectStateEvent(ConnectStateEvent.CHANGE_NETWORK));
//
}
}
}
},
2000
);
...
...
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