Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2020-01-14 16:05:59 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
af061752f5b68415fa95e60b24b90945464a35cb
af061752
1 parent
8b8a61ee
Add a timeout to onFinish()
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
printing/android/src/main/java/net/nfet/flutter/printing/PrintingJob.java
printing/android/src/main/java/net/nfet/flutter/printing/PrintingJob.java
View file @
af06175
...
...
@@ -134,22 +134,29 @@ public class PrintingJob extends PrintDocumentAdapter {
public
void
run
()
{
try
{
final
boolean
[]
wait
=
{
true
};
int
count
=
5
*
60
*
10
;
// That's 10 minutes.
while
(
wait
[
0
])
{
new
Handler
(
Looper
.
getMainLooper
()).
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
int
state
=
printJob
.
getInfo
().
getState
();
int
state
=
printJob
==
null
?
PrintJobInfo
.
STATE_FAILED
:
printJob
.
getInfo
().
getState
();
if
(
state
==
PrintJobInfo
.
STATE_COMPLETED
)
{
printing
.
onCompleted
(
PrintingJob
.
this
,
true
,
""
);
wait
[
0
]
=
false
;
}
else
if
(
state
==
PrintJobInfo
.
STATE_CANCELED
)
{
}
else
if
(
state
==
PrintJobInfo
.
STATE_CANCELED
||
state
==
PrintJobInfo
.
STATE_FAILED
)
{
printing
.
onCompleted
(
PrintingJob
.
this
,
false
,
"User canceled"
);
wait
[
0
]
=
false
;
}
}
});
if
(--
count
<=
0
)
{
throw
new
Exception
(
"Timeout waiting for the job to finish"
);
}
if
(
wait
[
0
])
{
Thread
.
sleep
(
200
);
}
...
...
Please
register
or
login
to post a comment