diff options
author | Paul Gardiner <paul.gardiner@artifex.com> | 2013-09-25 12:41:06 +0100 |
---|---|---|
committer | Paul Gardiner <paul.gardiner@artifex.com> | 2013-09-25 12:41:06 +0100 |
commit | 6a10189b6611d746b8dfbc6fb1f42d65beb708e3 (patch) | |
tree | 0a9bbdcef8ec3949a559105487c037a88c708c40 /platform/android/src/com/artifex | |
parent | 457d80c7612e07a8570ae47d27f53f1e0e125cc9 (diff) | |
download | mupdf-6a10189b6611d746b8dfbc6fb1f42d65beb708e3.tar.xz |
Android: while adjusting reflow zoom, refresh only the visible page
Also fix a race condition where an attempt to set the zoom might precede
the loading of html into the WebView
Diffstat (limited to 'platform/android/src/com/artifex')
-rw-r--r-- | platform/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java | 7 | ||||
-rw-r--r-- | platform/android/src/com/artifex/mupdfdemo/ReaderView.java | 17 |
2 files changed, 16 insertions, 8 deletions
diff --git a/platform/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java b/platform/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java index eb655656..02a083e1 100644 --- a/platform/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java +++ b/platform/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java @@ -16,6 +16,7 @@ public class MuPDFReflowView extends WebView implements MuPDFView { private final Handler mHandler; private final Point mParentSize; private int mPage; + private float mScale; private int mContentHeight; AsyncTask<Void,Void,byte[]> mLoadHTML; @@ -24,6 +25,7 @@ public class MuPDFReflowView extends WebView implements MuPDFView { mHandler = new Handler(); mCore = core; mParentSize = parentSize; + mScale = 1.0f; mContentHeight = parentSize.y; getSettings().setJavaScriptEnabled(true); addJavascriptInterface(new Object(){ @@ -39,7 +41,7 @@ public class MuPDFReflowView extends WebView implements MuPDFView { setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { - requestHeight(); + setScale(mScale); } }); } @@ -74,7 +76,8 @@ public class MuPDFReflowView extends WebView implements MuPDFView { } public void setScale(float scale) { - loadUrl("javascript:document.getElementById('content').style.zoom=\""+(int)(scale*100)+"%\""); + mScale = scale; + loadUrl("javascript:document.getElementById('content').style.zoom=\""+(int)(mScale*100)+"%\""); requestHeight(); } diff --git a/platform/android/src/com/artifex/mupdfdemo/ReaderView.java b/platform/android/src/com/artifex/mupdfdemo/ReaderView.java index 9ec572a3..f779372b 100644 --- a/platform/android/src/com/artifex/mupdfdemo/ReaderView.java +++ b/platform/android/src/com/artifex/mupdfdemo/ReaderView.java @@ -436,12 +436,9 @@ public class ReaderView mScale = Math.min(Math.max(mScale * detector.getScaleFactor(), min_scale), max_scale); if (mReflow) { - applyToChildren(new ViewMapper() { - @Override - void applyToView(View view) { - onScaleChild(view, mScale); - } - }); + View v = mChildViews.get(mCurrent); + if (v != null) + onScaleChild(v, mScale); } else { float factor = mScale/previousScale; @@ -472,6 +469,14 @@ public class ReaderView } public void onScaleEnd(ScaleGestureDetector detector) { + if (mReflow) { + applyToChildren(new ViewMapper() { + @Override + void applyToView(View view) { + onScaleChild(view, mScale); + } + }); + } mScaling = false; } |