Observable.just(RetrofitHelper.API_BASE_URL + img)
.subscribeOn(Schedulers.newThread())
.subscribe(new Action1<String>() {
@Override
public void call(String s) {
try {
Glide.with(getApplicationContext())
.load(s)
.downloadOnly(720, 1280)
.get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
});
File file = new File(sp_splash_logo);
if (file.exists()) {
Glide.with(getApplicationContext()).load(file).into(mIvSplash);
} else {
mIvSplash.setImageResource(R.mipmap.splash);
}
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(RetrofitHelper.API_BASE_URL)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
ImgServise imgServise = retrofit.create(ImgServise.class);
imgServise.downloadPicFromNet(img)
.subscribeOn(Schedulers.newThread())
.subscribe(new Action1<ResponseBody>() {
@Override
public void call(ResponseBody responseBody) {
try {
long contentLength = responseBody.contentLength();
InputStream is = responseBody.byteStream();
File file = new File(Environment.getExternalStorageDirectory(), BuildConfig.APPLICATION_ID + "splash.png");
FileOutputStream fos = new FileOutputStream(file);
BufferedInputStream bis = new BufferedInputStream(is);
byte[] buffer = new byte[1024];
int len;
long sum = 0L;
while ((len = bis.read(buffer)) != -1) {
fos.write(buffer, 0, len);
sum += len;
fos.flush();
//增加下载进度的获取
Log.d("TAG---", sum + "/" + contentLength);
}
fos.close();
bis.close();
is.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
stopSelf();
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
stopSelf();
}
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有