mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Cache our compat lookups for our message webview - (They're expensive on
older devices - and pointless not to reuse)
This commit is contained in:
parent
7e9ccf283a
commit
767352515f
@ -81,7 +81,10 @@ public class TitleBarWebView extends WebView implements TitleBarDelegate {
|
|||||||
boolean mTouchMove;
|
boolean mTouchMove;
|
||||||
private Rect mClipBounds = new Rect();
|
private Rect mClipBounds = new Rect();
|
||||||
private Matrix mMatrix = new Matrix();
|
private Matrix mMatrix = new Matrix();
|
||||||
private Method mNativeGetVisibleTitleHeightMethod;
|
private static boolean checkedForNativeGetVisibleTitleHeightMethod = false;
|
||||||
|
private static Method nativeGetVisibleTitleHeightMethod;
|
||||||
|
private static Method nativeSetEmbeddedTitleBarMethod;
|
||||||
|
private static boolean checkedForNativeSetEmbeddedTitleBarMethod = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will always contain a reference to the title bar view no matter if
|
* This will always contain a reference to the title bar view no matter if
|
||||||
@ -171,16 +174,23 @@ public class TitleBarWebView extends WebView implements TitleBarDelegate {
|
|||||||
* @param v The view to set or null for removing the title bar view.
|
* @param v The view to set or null for removing the title bar view.
|
||||||
*/
|
*/
|
||||||
public void setEmbeddedTitleBarCompat(View v) {
|
public void setEmbeddedTitleBarCompat(View v) {
|
||||||
|
if(checkedForNativeSetEmbeddedTitleBarMethod && nativeSetEmbeddedTitleBarMethod == null) {
|
||||||
|
setEmbeddedTitleBarJellyBean(v);
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
Method nativeMethod = getClass().getMethod("setEmbeddedTitleBar",
|
|
||||||
|
if (nativeSetEmbeddedTitleBarMethod == null) {
|
||||||
|
nativeSetEmbeddedTitleBarMethod = getClass().getMethod("setEmbeddedTitleBar",
|
||||||
View.class);
|
View.class);
|
||||||
nativeMethod.invoke(this, v);
|
checkedForNativeSetEmbeddedTitleBarMethod = true;
|
||||||
|
}
|
||||||
|
nativeSetEmbeddedTitleBarMethod.invoke(this, v);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
Log.d(TAG,
|
Log.d(TAG,
|
||||||
"Native setEmbeddedTitleBar not available. Starting workaround");
|
"Native setEmbeddedTitleBar not available. Starting workaround");
|
||||||
setEmbeddedTitleBarJellyBean(v);
|
setEmbeddedTitleBarJellyBean(v);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mTitleBarView = v;
|
mTitleBarView = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,9 +232,9 @@ public class TitleBarWebView extends WebView implements TitleBarDelegate {
|
|||||||
* @return Visible height of title bar view or 0 if not set.
|
* @return Visible height of title bar view or 0 if not set.
|
||||||
*/
|
*/
|
||||||
protected int getVisibleTitleHeightCompat() {
|
protected int getVisibleTitleHeightCompat() {
|
||||||
if(mTitleBar == null && mNativeGetVisibleTitleHeightMethod != null) {
|
if(mTitleBar == null && nativeGetVisibleTitleHeightMethod != null) {
|
||||||
try {
|
try {
|
||||||
return (Integer) mNativeGetVisibleTitleHeightMethod
|
return (Integer) nativeGetVisibleTitleHeightMethod
|
||||||
.invoke(this);
|
.invoke(this);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
}
|
}
|
||||||
@ -310,13 +320,17 @@ public class TitleBarWebView extends WebView implements TitleBarDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
if (checkedForNativeGetVisibleTitleHeightMethod == false) {
|
||||||
try {
|
try {
|
||||||
mNativeGetVisibleTitleHeightMethod = WebView.class
|
nativeGetVisibleTitleHeightMethod = WebView.class
|
||||||
.getDeclaredMethod("getVisibleTitleHeight");
|
.getDeclaredMethod("getVisibleTitleHeight");
|
||||||
} catch(NoSuchMethodException e) {
|
} catch(NoSuchMethodException e) {
|
||||||
Log.w(TAG,
|
Log.w(TAG,
|
||||||
"Could not retrieve native hidden getVisibleTitleHeight method");
|
"Could not retrieve native hidden getVisibleTitleHeight method");
|
||||||
}
|
}
|
||||||
|
checkedForNativeGetVisibleTitleHeightMethod = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user