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 10:18:07 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8b8a61eec7427ea5cb86b192e79beb6f3f7ee463
8b8a61ee
1 parent
b45573df
Fix Android app freeze
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
15 deletions
printing/CHANGELOG.md
printing/android/src/main/java/net/nfet/flutter/printing/PrintingJob.java
printing/CHANGELOG.md
View file @
8b8a61e
...
...
@@ -3,6 +3,7 @@
## 3.1.0
-
Migrate to the new Android plugins APIs
-
Fix Android app freeze
## 3.0.2
...
...
printing/android/src/main/java/net/nfet/flutter/printing/PrintingJob.java
View file @
8b8a61e
...
...
@@ -128,25 +128,47 @@ public class PrintingJob extends PrintDocumentAdapter {
@Override
public
void
onFinish
()
{
try
{
while
(
true
)
{
int
state
=
printJob
.
getInfo
().
getState
();
if
(
state
==
PrintJobInfo
.
STATE_COMPLETED
)
{
printing
.
onCompleted
(
this
,
true
,
""
);
break
;
}
else
if
(
state
==
PrintJobInfo
.
STATE_CANCELED
)
{
printing
.
onCompleted
(
this
,
false
,
"User canceled"
);
break
;
Thread
thread
=
new
Thread
(
new
Runnable
()
{
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
LOLLIPOP
)
@Override
public
void
run
()
{
try
{
final
boolean
[]
wait
=
{
true
};
while
(
wait
[
0
])
{
new
Handler
(
Looper
.
getMainLooper
()).
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
int
state
=
printJob
.
getInfo
().
getState
();
if
(
state
==
PrintJobInfo
.
STATE_COMPLETED
)
{
printing
.
onCompleted
(
PrintingJob
.
this
,
true
,
""
);
wait
[
0
]
=
false
;
}
else
if
(
state
==
PrintJobInfo
.
STATE_CANCELED
)
{
printing
.
onCompleted
(
PrintingJob
.
this
,
false
,
"User canceled"
);
wait
[
0
]
=
false
;
}
}
});
if
(
wait
[
0
])
{
Thread
.
sleep
(
200
);
}
}
}
catch
(
final
Exception
e
)
{
new
Handler
(
Looper
.
getMainLooper
()).
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
printing
.
onCompleted
(
PrintingJob
.
this
,
printJob
!=
null
&&
printJob
.
isCompleted
(),
e
.
getMessage
());
}
});
}
Thread
.
sleep
(
200
)
;
printJob
=
null
;
}
}
catch
(
Exception
e
)
{
printing
.
onCompleted
(
this
,
printJob
!=
null
&&
printJob
.
isCompleted
(),
e
.
getMessage
());
}
});
printJob
=
null
;
thread
.
start
()
;
}
void
printPdf
(
@NonNull
String
name
,
Double
width
,
Double
height
,
Double
marginLeft
,
...
...
Please
register
or
login
to post a comment