Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[webview_flutter_android] Copies Android implementation of webview_flutter from v4_webview #6851

Merged
merged 4 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 3.0.0

* **BREAKING CHANGE** Updates platform implementation to `2.0.0` release of
`webview_flutter_platform_interface`. See
[webview_flutter](https://pub.dev/packages/webview_flutter/versions/4.0.0) for updated usage.

## 2.10.4

* Updates code for `no_leading_underscores_for_local_identifiers` lint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,6 @@ public void onDownloadStart(
callback);
}

/**
* Communicates to Dart that the reference to a {@link DownloadListener} was removed.
*
* @param downloadListener the instance whose reference will be removed
* @param callback reply callback with return value from Dart
*/
public void dispose(DownloadListener downloadListener, Reply<Void> callback) {
if (instanceManager.containsInstance(downloadListener)) {
dispose(getIdentifierForListener(downloadListener), callback);
} else {
callback.reply(null);
}
}

private long getIdentifierForListener(DownloadListener listener) {
final Long identifier = instanceManager.getIdentifierForStrongReference(listener);
if (identifier == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import android.webkit.DownloadListener;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import io.flutter.plugins.webviewflutter.GeneratedAndroidWebView.DownloadListenerHostApi;

/**
Expand All @@ -21,11 +20,9 @@ public class DownloadListenerHostApiImpl implements DownloadListenerHostApi {

/**
* Implementation of {@link DownloadListener} that passes arguments of callback methods to Dart.
*
* <p>No messages are sent to Dart after {@link DownloadListenerImpl#release} is called.
*/
public static class DownloadListenerImpl implements DownloadListener, Releasable {
@Nullable private DownloadListenerFlutterApiImpl flutterApi;
public static class DownloadListenerImpl implements DownloadListener {
private final DownloadListenerFlutterApiImpl flutterApi;

/**
* Creates a {@link DownloadListenerImpl} that passes arguments of callbacks methods to Dart.
Expand All @@ -43,18 +40,8 @@ public void onDownloadStart(
String contentDisposition,
String mimetype,
long contentLength) {
if (flutterApi != null) {
flutterApi.onDownloadStart(
this, url, userAgent, contentDisposition, mimetype, contentLength, reply -> {});
}
}

@Override
public void release() {
if (flutterApi != null) {
flutterApi.dispose(this, reply -> {});
}
flutterApi = null;
flutterApi.onDownloadStart(
this, url, userAgent, contentDisposition, mimetype, contentLength, reply -> {});
}
}

Expand Down
Loading