Package com.unblu.sdk.core.configuration
Interface UnbluDownloadHandler
public interface UnbluDownloadHandler
Handler for downloads. The download handler has to deal with the entire download process, requesting the file, handling storage permissions, storing the file at some location and so on.
-
Method Summary
Modifier and TypeMethodDescriptionstatic UnbluDownloadHandler
createExternalStorageDownloadHandler
(android.app.Application application) Creates a default implementation ofUnbluDownloadHandler
that stores downloaded files in the public downloads directory.void
onDownloadStart
(com.unblu.sdk.core.internal.utils.IApplicationStateProvider applicationStateProvider, String requestedUrl, String userAgent, String contentDisposition, String mimeType, long contentLength, String cookies) Triggered whenever a download is started.default void
onDownloadStart
(com.unblu.sdk.core.internal.utils.IApplicationStateProvider applicationStateProvider, String requestedUrl, String userAgent, String contentDisposition, String mimeType, long contentLength, String cookies, String oAuthToken) Triggered whenever a download is started.default void
Called whenever the webView is destroyed.default void
Called whenever the webView is initialized.
-
Method Details
-
createExternalStorageDownloadHandler
static UnbluDownloadHandler createExternalStorageDownloadHandler(android.app.Application application) Creates a default implementation ofUnbluDownloadHandler
that stores downloaded files in the public downloads directory.- Parameters:
application
- The application instance- Returns:
- The default implementation using
SharedPreferences
-
onDownloadStart
void onDownloadStart(com.unblu.sdk.core.internal.utils.IApplicationStateProvider applicationStateProvider, String requestedUrl, String userAgent, String contentDisposition, String mimeType, long contentLength, String cookies) Triggered whenever a download is started. Except for the cookies, this matches theDownloadListener
ofWebView
.If you need the MIME type and content disposition but they're missing, you can use an additional HEAD request to retrieve them from the server.
- Parameters:
applicationStateProvider
- The applicationStateProvider to check for the active activityrequestedUrl
- The full URL to the content that should be downloadeduserAgent
- The user agent for the downloadcontentDisposition
- The Content-Disposition HTTP header, if presentmimeType
- The MIME type of the content, as reported by the servercookies
- The cookies used inside the WebView that are relevant for this request. For example, you may need to add cookies to the request to gain access to the file.contentLength
- The Content-Length HTTP header
-
onDownloadStart
default void onDownloadStart(com.unblu.sdk.core.internal.utils.IApplicationStateProvider applicationStateProvider, String requestedUrl, String userAgent, String contentDisposition, String mimeType, long contentLength, String cookies, String oAuthToken) Triggered whenever a download is started. Except for the cookies, this matches theDownloadListener
ofWebView
s. Use this method if you set an OAuth token in the currentUnbluClientConfiguration
.If you need the MIME type and content disposition but they're missing, you can use an additional HEAD request to retrieve them from the server.
- Parameters:
applicationStateProvider
- The applicationStateProvider to check for the active activityrequestedUrl
- The full URL to the content that should be downloadeduserAgent
- the user agent to be used for the download.contentDisposition
- Content-disposition http header, if present.mimeType
- The mimeType of the content reported by the server.cookies
- The cookies used inside the WebView which are relevant for this request. They may have to be added to the request to have access to the file.contentLength
- Content-LengthoAuthToken
- optional oAuthToken,
-
onWebViewInitialize
default void onWebViewInitialize()Called whenever the webView is initialized. This happens during the initialization of the SDK.
The method can be used to do some initial setup, for example, to listen to the Android https://developer.android.com/reference/android/app/DownloadManager[`DownloadManager`^]. -
onWebViewDestroy
default void onWebViewDestroy()Called whenever the webView is destroyed. This happens when the SDK is deinitialized.
The method can be used to do some cleanup, for example of listeners on the Android https://developer.android.com/reference/android/app/DownloadManager[`DownloadManager`^].
-