From bad6872f69d2f2f2ca208a31477a679b45ed59f2 Mon Sep 17 00:00:00 2001 From: Anthony Restaino Date: Fri, 3 Apr 2015 09:14:29 -0400 Subject: [PATCH] Improved TextReflow on Kitkat and up --- src/acr/browser/lightning/LightningView.java | 29 +++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/acr/browser/lightning/LightningView.java b/src/acr/browser/lightning/LightningView.java index f0cadae..d6f254d 100644 --- a/src/acr/browser/lightning/LightningView.java +++ b/src/acr/browser/lightning/LightningView.java @@ -744,24 +744,27 @@ public class LightningView { } - boolean isRunning = false; + private boolean mIsRunning = false; + private float mZoomScale = 0.0f; @Override public void onScaleChanged(final WebView view, final float oldScale, final float newScale) { if (view.isShown() && mTextReflow && API >= android.os.Build.VERSION_CODES.KITKAT) { - view.invalidate(); - if (isRunning) + if (mIsRunning) return; - isRunning = view.postDelayed(new Runnable() { - - @Override - public void run() { - // TODO - view.evaluateJavascript(Constants.JAVASCRIPT_TEXT_REFLOW, null); - isRunning = false; - } - - }, 100); + if (Math.abs(mZoomScale - newScale) > 0.01f) { + mIsRunning = view.postDelayed(new Runnable() { + + @Override + public void run() { + mZoomScale = newScale; + view.evaluateJavascript(Constants.JAVASCRIPT_TEXT_REFLOW, null); + Log.d("YOLO", "SCALE CHANGING " + newScale); + mIsRunning = false; + } + + }, 100); + } } }