From 7be600d8e918d5528f98bd3394c307de2709b7e0 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Thu, 19 Feb 2015 10:28:18 -0500 Subject: [PATCH] Make cookieManager a field in AndroidCookieManager rather than using getInstance() every time --- .../apache/cordova/AndroidCookieManager.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/framework/src/org/apache/cordova/AndroidCookieManager.java b/framework/src/org/apache/cordova/AndroidCookieManager.java index 09d3a0f2..16eaa7a8 100644 --- a/framework/src/org/apache/cordova/AndroidCookieManager.java +++ b/framework/src/org/apache/cordova/AndroidCookieManager.java @@ -24,38 +24,37 @@ import android.webkit.CookieManager; import android.webkit.WebView; class AndroidCookieManager implements ICordovaCookieManager { - - protected WebView webView; + protected final WebView webView; + private final CookieManager cookieManager; public AndroidCookieManager(WebView webview) { webView = webview; + cookieManager = CookieManager.getInstance(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) - { - CookieManager cookieManager = CookieManager.getInstance(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { cookieManager.setAcceptThirdPartyCookies(webView, true); } } public void setCookiesEnabled(boolean accept) { - CookieManager.getInstance().setAcceptCookie(accept); + cookieManager.setAcceptCookie(accept); } public void setCookie(final String url, final String value) { - CookieManager.getInstance().setCookie(url, value); + cookieManager.setCookie(url, value); } public String getCookie(final String url) { - return CookieManager.getInstance().getCookie(url); + return cookieManager.getCookie(url); } public void clearCookies() { - CookieManager.getInstance().removeAllCookie(); + cookieManager.removeAllCookie(); } public void flush() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - CookieManager.getInstance().flush(); + cookieManager.flush(); } } };