com.liulishuo.filedownloader.services.DownloadMgrInitialParams Java Examples
The following examples show how to use
com.liulishuo.filedownloader.services.DownloadMgrInitialParams.
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: ApplicationModule.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@Provides @Singleton FileDownloaderProvider providesFileDownloaderProvider( @Named("cachePath") String cachePath, @Named("user-agent") Interceptor userAgentInterceptor, AuthenticationPersistence authenticationPersistence, DownloadAnalytics downloadAnalytics, InstallAnalytics installAnalytics, Md5Comparator md5Comparator) { final OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder().addInterceptor(userAgentInterceptor) .addInterceptor(new DownloadMirrorEventInterceptor(downloadAnalytics, installAnalytics)) .connectTimeout(20, TimeUnit.SECONDS) .writeTimeout(20, TimeUnit.SECONDS) .readTimeout(20, TimeUnit.SECONDS); FileDownloader.init(application, new DownloadMgrInitialParams.InitCustomMaker().connectionCreator( new OkHttp3Connection.Creator(httpClientBuilder))); return new FileDownloadManagerProvider(cachePath, FileDownloader.getImpl(), md5Comparator); }
Example #2
Source File: FileDownloader.java From FileDownloader with Apache License 2.0 | 6 votes |
/** * @deprecated please using {@link #setupOnApplicationOnCreate(Application)} instead. */ public static void init(final Context context, final DownloadMgrInitialParams.InitCustomMaker maker) { if (FileDownloadLog.NEED_LOG) { FileDownloadLog.d(FileDownloader.class, "init Downloader with params: %s %s", context, maker); } if (context == null) { throw new IllegalArgumentException("the provided context must not be null!"); } FileDownloadHelper.holdContext(context.getApplicationContext()); CustomComponentHolder.getImpl().setInitCustomMaker(maker); }
Example #3
Source File: CustomComponentHolder.java From FileDownloader with Apache License 2.0 | 5 votes |
public void setInitCustomMaker(DownloadMgrInitialParams.InitCustomMaker initCustomMaker) { synchronized (this) { initialParams = new DownloadMgrInitialParams(initCustomMaker); connectionCreator = null; outputStreamCreator = null; database = null; idGenerator = null; } }
Example #4
Source File: FileDownloader.java From okdownload with Apache License 2.0 | 3 votes |
/** * Using this method to setup the FileDownloader only you want to register your own customize * components for Filedownloader, otherwise just using {@link #setup(Context)} instead. * <p/> * Please invoke this method on the {@link Application#onCreate()} because of the customize * components must be assigned before FileDownloader is running. * <p/> * Such as: * <p/> * class MyApplication extends Application { * ... * public void onCreate() { * ... * FileDownloader.setupOnApplicationOnCreate(this) * .idGenerator(new MyIdGenerator()) * .database(new MyDatabase()) * ... * .commit(); * ... * } * ... * } * * @param application the application. * @return the customize components maker. */ public static DownloadMgrInitialParams.InitCustomMaker setupOnApplicationOnCreate( Application application) { final Context context = application.getApplicationContext(); DownloadMgrInitialParams.InitCustomMaker customMaker = new DownloadMgrInitialParams.InitCustomMaker(context); return customMaker; }
Example #5
Source File: FileDownloader.java From FileDownloader with Apache License 2.0 | 3 votes |
/** * Using this method to setup the FileDownloader only you want to register your own customize * components for Filedownloader, otherwise just using {@link #setup(Context)} instead. * <p/> * Please invoke this method on the {@link Application#onCreate()} because of the customize * components must be assigned before FileDownloader is running. * <p/> * Such as: * <p/> * class MyApplication extends Application { * ... * public void onCreate() { * ... * FileDownloader.setupOnApplicationOnCreate(this) * .idGenerator(new MyIdGenerator()) * .database(new MyDatabase()) * ... * .commit(); * ... * } * ... * } * @param application the application. * @return the customize components maker. */ public static DownloadMgrInitialParams.InitCustomMaker setupOnApplicationOnCreate( Application application) { final Context context = application.getApplicationContext(); FileDownloadHelper.holdContext(context); DownloadMgrInitialParams.InitCustomMaker customMaker = new DownloadMgrInitialParams.InitCustomMaker(); CustomComponentHolder.getImpl().setInitCustomMaker(customMaker); return customMaker; }