mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-09 12:48:02 -05:00
Do less work in RigidWebView in 'no throttle' case
This commit is contained in:
parent
504e99eeea
commit
efc129fcd0
@ -35,6 +35,7 @@ import com.fsck.k9.helper.Utility;
|
|||||||
* contents with percent-based height will force the WebView to infinitely expand (or shrink).
|
* contents with percent-based height will force the WebView to infinitely expand (or shrink).
|
||||||
*/
|
*/
|
||||||
public class RigidWebView extends WebView {
|
public class RigidWebView extends WebView {
|
||||||
|
private static final boolean NO_THROTTLE = Build.VERSION.SDK_INT >= 21; //Build.VERSION_CODES.LOLLIPOP
|
||||||
|
|
||||||
public RigidWebView(Context context) {
|
public RigidWebView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@ -46,7 +47,6 @@ public class RigidWebView extends WebView {
|
|||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean noThrottle = Build.VERSION.SDK_INT >= 21; //Build.VERSION_CODES.LOLLIPOP
|
|
||||||
private static final int MIN_RESIZE_INTERVAL = 200;
|
private static final int MIN_RESIZE_INTERVAL = 200;
|
||||||
private static final int MAX_RESIZE_INTERVAL = 300;
|
private static final int MAX_RESIZE_INTERVAL = 300;
|
||||||
private final Clock mClock = Clock.INSTANCE;
|
private final Clock mClock = Clock.INSTANCE;
|
||||||
@ -66,15 +66,14 @@ public class RigidWebView extends WebView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSizeChanged(int w, int h, int ow, int oh) {
|
protected void onSizeChanged(int w, int h, int ow, int oh) {
|
||||||
mRealWidth = w;
|
if (NO_THROTTLE) {
|
||||||
mRealHeight = h;
|
super.onSizeChanged(w, h, ow, oh);
|
||||||
|
|
||||||
// Don't throttle resizes on Android 5 or higher.
|
|
||||||
if (noThrottle) {
|
|
||||||
performSizeChange(ow, oh);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mRealWidth = w;
|
||||||
|
mRealHeight = h;
|
||||||
|
|
||||||
long now = mClock.getTime();
|
long now = mClock.getTime();
|
||||||
boolean recentlySized = (now - mLastSizeChangeTime < MIN_RESIZE_INTERVAL);
|
boolean recentlySized = (now - mLastSizeChangeTime < MIN_RESIZE_INTERVAL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user