fix leaking MethodChannel through anonymous class

This commit is contained in:
Eugene Makar 2022-05-27 09:29:50 +03:00
parent ee1b0d7ff7
commit bd6e2548fc
1 changed files with 11 additions and 7 deletions

View File

@ -168,13 +168,7 @@ public class ServiceWorkerManager implements MethodChannel.MethodCallHandler {
}
private ServiceWorkerClientCompat dummyServiceWorkerClientCompat() {
return new ServiceWorkerClientCompat() {
@Nullable
@Override
public WebResourceResponse shouldInterceptRequest(@NonNull WebResourceRequest request) {
return null;
}
};
return DummyServiceWorkerClientCompat.INSTANCE;
}
public void dispose() {
@ -185,4 +179,14 @@ public class ServiceWorkerManager implements MethodChannel.MethodCallHandler {
}
plugin = null;
}
private static final class DummyServiceWorkerClientCompat extends ServiceWorkerClientCompat {
static final ServiceWorkerClientCompat INSTANCE = new DummyServiceWorkerClientCompat();
@Nullable
@Override
public WebResourceResponse shouldInterceptRequest(@NonNull WebResourceRequest request) {
return null;
}
}
}