Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
miya-hardware
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pengguangpu
miya-hardware
Commits
4e5c9f23
Commit
4e5c9f23
authored
Feb 18, 2019
by
pengguangpu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加内部自带重试逻辑的连接检测
parent
52a50a41
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
PrinterManager.java
print/src/main/java/com/miya/print/PrinterManager.java
+21
-0
No files found.
print/src/main/java/com/miya/print/PrinterManager.java
View file @
4e5c9f23
...
@@ -67,12 +67,18 @@ public class PrinterManager {
...
@@ -67,12 +67,18 @@ public class PrinterManager {
*/
*/
IPrinter
printer
;
IPrinter
printer
;
/**
* 内部持有调用者初始化的应用
*/
Context
ctx
;
/**
/**
* 轮询初始化
* 轮询初始化
*
*
* @return 是否初始化成功
* @return 是否初始化成功
*/
*/
public
boolean
init
(
Context
context
)
{
public
boolean
init
(
Context
context
)
{
this
.
ctx
=
context
;
for
(
Type
type
:
Type
.
values
())
{
for
(
Type
type
:
Type
.
values
())
{
try
{
try
{
if
(
printer
!=
null
)
{
if
(
printer
!=
null
)
{
...
@@ -138,6 +144,7 @@ public class PrinterManager {
...
@@ -138,6 +144,7 @@ public class PrinterManager {
* @return
* @return
*/
*/
public
boolean
init
(
Context
context
,
Type
type
)
{
public
boolean
init
(
Context
context
,
Type
type
)
{
this
.
ctx
=
context
;
if
(
type
==
null
)
{
if
(
type
==
null
)
{
return
false
;
return
false
;
}
}
...
@@ -184,4 +191,18 @@ public class PrinterManager {
...
@@ -184,4 +191,18 @@ public class PrinterManager {
public
boolean
isConnected
()
{
public
boolean
isConnected
()
{
return
printer
!=
null
;
return
printer
!=
null
;
}
}
/**
* 自带初始化重试的检测逻辑
*
* @return 如果printer!=null则返回true,否则内部初始化一次再返回初始化结果
*/
public
boolean
checkIsConnectedWithRetry
()
{
if
(
printer
!=
null
)
{
return
true
;
}
else
if
(
ctx
!=
null
)
{
return
init
(
ctx
);
}
return
false
;
}
}
}
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