using getWebViewLooper API for Android 28+
This commit is contained in:
parent
2eb31ee74f
commit
254ba1a1b8
|
@ -35,7 +35,7 @@ public class JavaScriptBridgeInterface {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Handler handler = new Handler(Looper.getMainLooper());
|
final Handler handler = new Handler(inAppWebView.getWebViewLooper());
|
||||||
handler.post(new Runnable() {
|
handler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -58,7 +58,7 @@ public class JavaScriptBridgeInterface {
|
||||||
|
|
||||||
// java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread.
|
// java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread.
|
||||||
// https://github.com/pichillilorenzo/flutter_inappwebview/issues/98
|
// https://github.com/pichillilorenzo/flutter_inappwebview/issues/98
|
||||||
final Handler handler = new Handler(Looper.getMainLooper());
|
final Handler handler = new Handler(inAppWebView.getWebViewLooper());
|
||||||
handler.post(new Runnable() {
|
handler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class ContentBlockerHandler {
|
||||||
final String[] webViewUrl = new String[1];
|
final String[] webViewUrl = new String[1];
|
||||||
if (!trigger.getLoadType().isEmpty() || !trigger.getIfTopUrl().isEmpty() || !trigger.getUnlessTopUrl().isEmpty()) {
|
if (!trigger.getLoadType().isEmpty() || !trigger.getIfTopUrl().isEmpty() || !trigger.getUnlessTopUrl().isEmpty()) {
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
Handler handler = new Handler(Looper.getMainLooper());
|
Handler handler = new Handler(webView.getWebViewLooper());
|
||||||
handler.post(new Runnable() {
|
handler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -160,7 +160,7 @@ public class ContentBlockerHandler {
|
||||||
" d.addEventListener('DOMContentLoaded', function(event) { hide(); }); " +
|
" d.addEventListener('DOMContentLoaded', function(event) { hide(); }); " +
|
||||||
"})(document);";
|
"})(document);";
|
||||||
|
|
||||||
final Handler handler = new Handler(Looper.getMainLooper());
|
final Handler handler = new Handler(webView.getWebViewLooper());
|
||||||
handler.post(new Runnable() {
|
handler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -133,7 +133,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
|
||||||
public LinearLayout floatingContextMenu = null;
|
public LinearLayout floatingContextMenu = null;
|
||||||
@Nullable
|
@Nullable
|
||||||
public Map<String, Object> contextMenu = null;
|
public Map<String, Object> contextMenu = null;
|
||||||
public Handler mainLooperHandler = new Handler(Looper.getMainLooper());
|
public Handler mainLooperHandler = new Handler(getWebViewLooper());
|
||||||
static Handler mHandler = new Handler();
|
static Handler mHandler = new Handler();
|
||||||
|
|
||||||
public Runnable checkScrollStoppedTask;
|
public Runnable checkScrollStoppedTask;
|
||||||
|
@ -1672,6 +1672,14 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
|
||||||
webMessageListeners.clear();
|
webMessageListeners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Looper getWebViewLooper() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
return super.getWebViewLooper();
|
||||||
|
}
|
||||||
|
return Looper.getMainLooper();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postWebMessage(com.pichillilorenzo.flutter_inappwebview.types.WebMessage message, Uri targetOrigin, ValueCallback<String> callback) throws Exception {
|
public void postWebMessage(com.pichillilorenzo.flutter_inappwebview.types.WebMessage message, Uri targetOrigin, ValueCallback<String> callback) throws Exception {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.pichillilorenzo.flutter_inappwebview.types;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.http.SslCertificate;
|
import android.net.http.SslCertificate;
|
||||||
|
import android.os.Looper;
|
||||||
import android.webkit.ValueCallback;
|
import android.webkit.ValueCallback;
|
||||||
import android.webkit.WebMessage;
|
import android.webkit.WebMessage;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
@ -98,4 +99,5 @@ public interface InAppWebViewInterface {
|
||||||
void setWebMessageChannels(Map<String, WebMessageChannel> webMessageChannels);
|
void setWebMessageChannels(Map<String, WebMessageChannel> webMessageChannels);
|
||||||
void disposeWebMessageChannels();
|
void disposeWebMessageChannels();
|
||||||
void disposeWebMessageListeners();
|
void disposeWebMessageListeners();
|
||||||
|
Looper getWebViewLooper();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5271,6 +5271,10 @@ setTimeout(function() {
|
||||||
expect(await AndroidInAppWebViewController.getCurrentWebViewPackage(),
|
expect(await AndroidInAppWebViewController.getCurrentWebViewPackage(),
|
||||||
isNotNull);
|
isNotNull);
|
||||||
}, skip: !Platform.isAndroid);
|
}, skip: !Platform.isAndroid);
|
||||||
|
|
||||||
|
test('setWebContentsDebuggingEnabled', () async {
|
||||||
|
expect(AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true), completes);
|
||||||
|
}, skip: !Platform.isAndroid);
|
||||||
}, skip: !Platform.isAndroid);
|
}, skip: !Platform.isAndroid);
|
||||||
|
|
||||||
group('ios methods', () {
|
group('ios methods', () {
|
||||||
|
|
Loading…
Reference in New Issue