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
fcdb977b
authored
Mar 09, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复一个在非debug版本下串口读取失败会崩溃的问题(原因是debug布局未Inflate)
parent
48844894
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
app/src/main/java/com/bgycc/smartcanteen/MainActivity.java
+11
-6
No files found.
app/src/main/java/com/bgycc/smartcanteen/MainActivity.java
View file @
fcdb977b
...
...
@@ -116,7 +116,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
initViews
();
SCWebSocketClient
.
getInstance
().
getConnectStateEvent
().
observe
(
this
,
event
->
{
if
(
debug
Vs
!=
null
)
return
;
if
(
debug
LayoutIsNotInflate
()
)
return
;
String
networkType
=
NetworkUtils
.
getNetworkType
(
this
);
String
msg
;
switch
(
event
.
getState
())
{
...
...
@@ -154,7 +154,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
String
log
=
"支付进度: "
+
time
+
" - "
+
event
.
getMessage
();
LogUtils
.
file
(
TAG
,
log
);
if
(
debug
Vs
!=
null
)
return
;
if
(
debug
LayoutIsNotInflate
()
)
return
;
sendText
.
setText
(
log
);
break
;
case
PayOnlineState
.
SUCCESS
:
...
...
@@ -207,7 +207,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
}
if
(
debug
Vs
!=
null
)
return
;
if
(
debug
LayoutIsNotInflate
()
)
return
;
String
msg
;
if
(
data
!=
null
)
{
msg
=
String
.
format
(
Locale
.
getDefault
(),
getString
(
R
.
string
.
qrcode_text
),
data
.
getPayCode
());
...
...
@@ -224,6 +224,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
qrCodeViewModel
.
scan
();
break
;
case
QRCodeState
.
ILLEGAL
:
if
(
debugLayoutIsNotInflate
())
return
;
message
.
setVisibility
(
View
.
GONE
);
sendText
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
serial_port_error
));
sendText
.
setText
(
R
.
string
.
serial_port_init_failed
);
...
...
@@ -264,8 +265,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
SCWebSocketClient
.
getInstance
().
tryConnect
();
}
private
boolean
debugLayoutIsNotInflate
()
{
return
debugVs
!=
null
;
}
private
void
toggleDebugLayout
()
{
if
(
debug
Vs
!=
null
)
{
if
(
debug
LayoutIsNotInflate
()
)
{
inflateDebugLayout
();
}
else
{
if
(
debugLayout
.
getVisibility
()
==
View
.
GONE
)
{
...
...
@@ -292,7 +297,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
String
successLog
=
"支付成功: "
+
successTime
+
" - "
+
successMessage
;
LogUtils
.
file
(
TAG
,
successLog
);
if
(
debug
Vs
!=
null
)
return
;
if
(
debug
LayoutIsNotInflate
()
)
return
;
recText
.
setText
(
successLog
);
}
...
...
@@ -310,7 +315,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
String
failedLog
=
"支付失败: "
+
failedTime
+
" - "
+
failedMessage
;
LogUtils
.
file
(
TAG
,
failedLog
);
if
(
debug
Vs
!=
null
)
return
;
if
(
debug
LayoutIsNotInflate
()
)
return
;
recText
.
setText
(
failedLog
);
}
...
...
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