mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
feat(core): android cookie manager setup (#10657)
This commit is contained in:
@ -73,6 +73,8 @@
|
|||||||
public error: java.lang.Exception;
|
public error: java.lang.Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setCookieManager(cookieManager: java.net.CookieManager): void;
|
||||||
|
export function initializeCookieManager(): java.net.CookieManager;
|
||||||
export function MakeRequest(options: RequestOptions, callback: CompleteCallback, context: any);
|
export function MakeRequest(options: RequestOptions, callback: CompleteCallback, context: any);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,11 +297,33 @@ public class Async {
|
|||||||
private static final String HEAD_METHOD = "HEAD";
|
private static final String HEAD_METHOD = "HEAD";
|
||||||
private static CookieManager cookieManager;
|
private static CookieManager cookieManager;
|
||||||
|
|
||||||
public static void MakeRequest(final RequestOptions options, final CompleteCallback callback, final Object context) {
|
public static void setCookieManager(CookieManager manager) {
|
||||||
|
if(manager == null) return;
|
||||||
|
|
||||||
|
cookieManager = manager;
|
||||||
|
if (CookieHandler.getDefault() == null) {
|
||||||
|
CookieHandler.setDefault(manager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CookieManager initializeCookieManager() {
|
||||||
if (cookieManager == null) {
|
if (cookieManager == null) {
|
||||||
|
CookieHandler defaultHandler = CookieHandler.getDefault();
|
||||||
|
if (defaultHandler instanceof CookieManager) {
|
||||||
|
cookieManager = (CookieManager) defaultHandler;
|
||||||
|
} else {
|
||||||
cookieManager = new CookieManager();
|
cookieManager = new CookieManager();
|
||||||
CookieHandler.setDefault(cookieManager);
|
CookieHandler.setDefault(cookieManager);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cookieManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void MakeRequest(final RequestOptions options, final CompleteCallback callback, final Object context) {
|
||||||
|
if (cookieManager == null) {
|
||||||
|
initializeCookieManager();
|
||||||
|
}
|
||||||
|
|
||||||
final android.os.Handler mHandler = new android.os.Handler(Looper.myLooper());
|
final android.os.Handler mHandler = new android.os.Handler(Looper.myLooper());
|
||||||
threadPoolExecutor().execute(new Runnable() {
|
threadPoolExecutor().execute(new Runnable() {
|
||||||
|
Reference in New Issue
Block a user