Java Code Examples for com.liulishuo.filedownloader.FileDownloader#init()

The following examples show how to use com.liulishuo.filedownloader.FileDownloader#init() . 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: App.java    From Simpler with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    // 所有Activity生命周期回调
    registerActivityLifecycleCallbacks(this);
    mInstance = this;
    // 实例化SharedPreferences
    prefs = getSharedPreferences(Constants.PREFS_NAME, MODE_PRIVATE);
    editor = prefs.edit();
    userServices = new UserServices(this);
    settingsServices = new SettingsServices(this);

    // 检查工作目录
    checkWorkDir();
    // 检查存储卡
    checkSdCard();
    // 友盟场景类型设置接口
    MobclickAgent.setScenarioType(this, MobclickAgent.EScenarioType.E_UM_NORMAL);
    // 初始化ApplicationToast
    AppToast.init(this);
    // FileDownloader全局初始化
    FileDownloader.init(getApplicationContext());
}
 
Example 2
Source File: ApplicationModule.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@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 3
Source File: bilI.java    From styT with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bilii);
    // FileDownloader.setup(this);
    FileDownloader.init(this);
    Intent intent = new Intent(this, DownloadService.class);
    startService(intent);
    bindService(intent, mServiceConnection, BIND_AUTO_CREATE);
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
    }

}
 
Example 4
Source File: MyApplication.java    From TLint with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    initComponent();
    initUser();
    FileDownloader.init(this, new FileDownloadHelper.OkHttpClientCustomMaker() {
        @Override
        public OkHttpClient customMake() {
            return mOkHttpClient;
        }
    });
    initFrescoConfig();
    ToastUtil.register(this);
    LeakCanary.install(this);
}
 
Example 5
Source File: DownloadHelper.java    From Mysplash with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void init(Context context) {
    FileDownloader.init(context);
}