This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Android WebView api with pigeon (Java portion) (#4441)
- Loading branch information
1 parent
0d33094
commit 42364e4
Showing
20 changed files
with
3,302 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
.../android/src/main/java/io/flutter/plugins/webviewflutter/DownloadListenerHostApiImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugins.webviewflutter; | ||
|
||
import android.webkit.DownloadListener; | ||
import io.flutter.plugins.webviewflutter.GeneratedAndroidWebView.DownloadListenerFlutterApi; | ||
|
||
class DownloadListenerHostApiImpl implements GeneratedAndroidWebView.DownloadListenerHostApi { | ||
private final InstanceManager instanceManager; | ||
private final DownloadListenerCreator downloadListenerCreator; | ||
private final GeneratedAndroidWebView.DownloadListenerFlutterApi downloadListenerFlutterApi; | ||
|
||
static class DownloadListenerCreator { | ||
DownloadListener createDownloadListener( | ||
Long instanceId, DownloadListenerFlutterApi downloadListenerFlutterApi) { | ||
return (url, userAgent, contentDisposition, mimetype, contentLength) -> | ||
downloadListenerFlutterApi.onDownloadStart( | ||
instanceId, url, userAgent, contentDisposition, mimetype, contentLength, reply -> {}); | ||
} | ||
} | ||
|
||
DownloadListenerHostApiImpl( | ||
InstanceManager instanceManager, | ||
DownloadListenerCreator downloadListenerCreator, | ||
DownloadListenerFlutterApi downloadListenerFlutterApi) { | ||
this.instanceManager = instanceManager; | ||
this.downloadListenerCreator = downloadListenerCreator; | ||
this.downloadListenerFlutterApi = downloadListenerFlutterApi; | ||
} | ||
|
||
@Override | ||
public void create(Long instanceId) { | ||
final DownloadListener downloadListener = | ||
downloadListenerCreator.createDownloadListener(instanceId, downloadListenerFlutterApi); | ||
instanceManager.addInstance(downloadListener, instanceId); | ||
} | ||
|
||
@Override | ||
public void dispose(Long instanceId) { | ||
instanceManager.removeInstance(instanceId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.