Skip to content

Commit

Permalink
[webview_flutter_android] Copies Android implementation of webview_fl…
Browse files Browse the repository at this point in the history
…utter from v4_webview (flutter#6851)

* new android release

* Version bump

* update all plugins config

* fix lints and add action item to changelog
  • Loading branch information
bparrishMines authored Dec 15, 2022
1 parent 6c0df1a commit 6bba843
Show file tree
Hide file tree
Showing 58 changed files with 9,761 additions and 4,164 deletions.
6 changes: 6 additions & 0 deletions packages/webview_flutter/webview_flutter_android/CHANGELOG.md
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

0 comments on commit 6bba843

Please sign in to comment.