summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-02-05 15:44:05 +0000
committerRobin Watts <robin.watts@artifex.com>2013-02-05 15:55:13 +0000
commit49b4eedf24212cac7ae0b94b855b219e4f1ae86f (patch)
tree2693c3e90ac733e6b429cf6fefec50a0a6ed9cb6 /android
parentcb3934ac4cb871629ab88f4c25d2c7a4c00f3d5e (diff)
downloadmupdf-49b4eedf24212cac7ae0b94b855b219e4f1ae86f.tar.xz
Android: Avoid SEGV on reflow on HTC Desire HD
Move the one time setup of the HTMLOUT javascript interface etc into the constructor. This seems to avoid the occasional SEGV caused while flipping pages on the HTC Desire in reflow mode.
Diffstat (limited to 'android')
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFReflowView.java27
1 files changed, 17 insertions, 10 deletions
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java b/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java
index dbca5af1..d689e9b2 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java
@@ -24,16 +24,6 @@ public class MuPDFReflowView extends WebView implements MuPDFView {
mCore = core;
mParentSize = parentSize;
mContentHeight = parentSize.y;
- }
-
- private void requestHeight() {
- // Get the webview to report the content height via the interface setup
- // above. Workaround for getContentHeight not working
- loadUrl("javascript:elem=document.getElementById('content');window.HTMLOUT.reportContentHeight("+mParentSize.x+"*elem.offsetHeight/elem.offsetWidth)");
- }
-
- public void setPage(int page, PointF size) {
- mPage = page;
getSettings().setJavaScriptEnabled(true);
addJavascriptInterface(new Object(){
public void reportContentHeight(String value) {
@@ -46,6 +36,19 @@ public class MuPDFReflowView extends WebView implements MuPDFView {
requestHeight();
}
});
+ }
+
+ private void requestHeight() {
+ // Get the webview to report the content height via the interface setup
+ // above. Workaround for getContentHeight not working
+ loadUrl("javascript:elem=document.getElementById('content');window.HTMLOUT.reportContentHeight("+mParentSize.x+"*elem.offsetHeight/elem.offsetWidth)");
+ }
+
+ public void setPage(int page, PointF size) {
+ mPage = page;
+ if (mLoadHTML != null) {
+ mLoadHTML.cancel(true);
+ }
mLoadHTML = new AsyncTask<Void,Void,byte[]>() {
@Override
protected byte[] doInBackground(Void... params) {
@@ -112,6 +115,10 @@ public class MuPDFReflowView extends WebView implements MuPDFView {
}
public void releaseResources() {
+ if (mLoadHTML != null) {
+ mLoadHTML.cancel(true);
+ mLoadHTML = null;
+ }
}
@Override