Java Code Examples for com.liulishuo.filedownloader.util.FileDownloadHelper#OutputStreamCreator

The following examples show how to use com.liulishuo.filedownloader.util.FileDownloadHelper#OutputStreamCreator . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DownloadMgrInitialParams.java    From FileDownloader with Apache License 2.0 6 votes vote down vote up
public FileDownloadHelper.OutputStreamCreator createOutputStreamCreator() {
    if (mMaker == null) {
        return createDefaultOutputStreamCreator();
    }

    final FileDownloadHelper.OutputStreamCreator outputStreamCreator =
            mMaker.mOutputStreamCreator;
    if (outputStreamCreator != null) {
        if (FileDownloadLog.NEED_LOG) {
            FileDownloadLog.d(this, "initial FileDownloader manager with the customize "
                    + "output stream: %s", outputStreamCreator);
        }
        return outputStreamCreator;
    } else {
        return createDefaultOutputStreamCreator();
    }
}
 
Example 2
Source File: DownloadMgrInitialParams.java    From FileDownloader with Apache License 2.0 6 votes vote down vote up
/**
 * Customize the output stream component.
 * <p>
 * If you don't customize the output stream component, we use the result of
 * {@link #createDefaultOutputStreamCreator()} as the default one.
 *
 * @param creator The output stream creator is used for creating
 *                {@link FileDownloadOutputStream} which is used to write the input stream
 *                to the file for downloading.
 */
public InitCustomMaker outputStreamCreator(FileDownloadHelper.OutputStreamCreator creator) {
    this.mOutputStreamCreator = creator;
    if (mOutputStreamCreator != null && !mOutputStreamCreator.supportSeek()) {
        if (!FileDownloadProperties.getImpl().fileNonPreAllocation) {
            throw new IllegalArgumentException(
                    "Since the provided FileDownloadOutputStream "
                            + "does not support the seek function, if FileDownloader"
                            + " pre-allocates file size at the beginning of the download,"
                            + " it will can not be resumed from the breakpoint. If you need"
                            + " to ensure that the resumption is available, please add and"
                            + " set the value of 'file.non-pre-allocation' field to 'true'"
                            + " in the 'filedownloader.properties' file which is in your"
                            + " application assets folder manually for resolving this "
                            + "problem.");
        }
    }
    return this;
}
 
Example 3
Source File: CustomComponentHolder.java    From FileDownloader with Apache License 2.0 5 votes vote down vote up
private FileDownloadHelper.OutputStreamCreator getOutputStreamCreator() {
    if (outputStreamCreator != null) return outputStreamCreator;

    synchronized (this) {
        if (outputStreamCreator == null) {
            outputStreamCreator = getDownloadMgrInitialParams().createOutputStreamCreator();
        }
    }

    return outputStreamCreator;
}
 
Example 4
Source File: DownloadOutputStreamAdapter.java    From okdownload with Apache License 2.0 4 votes vote down vote up
public Factory(@NonNull FileDownloadHelper.OutputStreamCreator creator) {
    this.creator = creator;
}
 
Example 5
Source File: DownloadMgrInitialParams.java    From FileDownloader with Apache License 2.0 4 votes vote down vote up
private FileDownloadHelper.OutputStreamCreator createDefaultOutputStreamCreator() {
    return new FileDownloadRandomAccessFile.Creator();
}
 
Example 6
Source File: DownloadMgrInitialParams.java    From okdownload with Apache License 2.0 2 votes vote down vote up
/**
 * Customize the output stream component.
 * <p>
 * If you don't customize the output stream component, we use the result of
 * {@link com.liulishuo.okdownload.core.file.DownloadUriOutputStream} as the default one.
 *
 * @param creator The output stream creator is used for creating
 *                {@link FileDownloadOutputStream} which is used to write the input stream
 *                to the file for downloading.
 */
public InitCustomMaker outputStreamCreator(FileDownloadHelper.OutputStreamCreator creator) {
    this.mOutputStreamCreator = creator;
    return this;
}