diff options
Diffstat (limited to 'platform/android/src/com/artifex/mupdfdemo')
-rw-r--r-- | platform/android/src/com/artifex/mupdfdemo/PageView.java | 9 | ||||
-rw-r--r-- | platform/android/src/com/artifex/mupdfdemo/ReaderView.java | 22 |
2 files changed, 16 insertions, 15 deletions
diff --git a/platform/android/src/com/artifex/mupdfdemo/PageView.java b/platform/android/src/com/artifex/mupdfdemo/PageView.java index cc00e004..3e30d1e5 100644 --- a/platform/android/src/com/artifex/mupdfdemo/PageView.java +++ b/platform/android/src/com/artifex/mupdfdemo/PageView.java @@ -539,9 +539,11 @@ public abstract class PageView extends ViewGroup { int h = bottom-top; if (mEntire != null) { - mEntireMat.setScale(w/(float)mSize.x, h/(float)mSize.y); - mEntire.setImageMatrix(mEntireMat); - mEntire.invalidate(); + if (mEntire.getWidth() != w || mEntire.getHeight() != h) { + mEntireMat.setScale(w/(float)mSize.x, h/(float)mSize.y); + mEntire.setImageMatrix(mEntireMat); + mEntire.invalidate(); + } mEntire.layout(0, 0, w, h); } @@ -631,7 +633,6 @@ public abstract class PageView extends ViewGroup { // Calling requestLayout here doesn't lead to a later call to layout. No idea // why, but apparently others have run into the problem. mPatch.layout(mPatchArea.left, mPatchArea.top, mPatchArea.right, mPatchArea.bottom); - invalidate(); } }; diff --git a/platform/android/src/com/artifex/mupdfdemo/ReaderView.java b/platform/android/src/com/artifex/mupdfdemo/ReaderView.java index f779372b..fe183945 100644 --- a/platform/android/src/com/artifex/mupdfdemo/ReaderView.java +++ b/platform/android/src/com/artifex/mupdfdemo/ReaderView.java @@ -47,6 +47,7 @@ public class ReaderView private int mXScroll; // Scroll amounts recorded from events. private int mYScroll; // and then accounted for in onLayout private boolean mReflow = false; + private boolean mReflowChanged = false; private final GestureDetector mGestureDetector; private final ScaleGestureDetector @@ -289,19 +290,12 @@ public class ReaderView public void refresh(boolean reflow) { mReflow = reflow; + mReflowChanged = true; + mResetLayout = true; mScale = 1.0f; mXScroll = mYScroll = 0; - int numChildren = mChildViews.size(); - for (int i = 0; i < numChildren; i++) { - View v = mChildViews.valueAt(i); - onNotInUse(v); - removeViewInLayout(v); - } - mChildViews.clear(); - mViewCache.clear(); - requestLayout(); } @@ -590,6 +584,13 @@ public class ReaderView removeViewInLayout(v); } mChildViews.clear(); + + // Don't reuse cached views if the adapter has changed + if (mReflowChanged) { + mReflowChanged = false; + mViewCache.clear(); + } + // post to ensure generation of hq area post(this); } @@ -668,8 +669,7 @@ public class ReaderView @Override public void setAdapter(Adapter adapter) { mAdapter = adapter; - mChildViews.clear(); - removeAllViewsInLayout(); + requestLayout(); } |