15
15
import com .face_chtj .base_iotutils .ToastUtils ;
16
16
import com .face_chtj .base_iotutils .callback .IDownloadCallback ;
17
17
import com .face_chtj .base_iotutils .DownloadUtils ;
18
- import com .face_chtj .base_iotutils .entity .FileCacheData ;
18
+ import com .face_chtj .base_iotutils .entity .FileData ;
19
19
import com .face_chtj .base_iotutils .NetUtils ;
20
20
import com .ichtj .basetools .R ;
21
21
import com .ichtj .basetools .base .BaseActivity ;
@@ -132,8 +132,8 @@ public void getdown_status(View view) {
132
132
* @param view
133
133
*/
134
134
public void downTaskPause1 (View view ) {
135
- if (fileCacheData != null ) {
136
- DownloadUtils .pause (fileCacheData .getRequestTag ());
135
+ if (fileData != null ) {
136
+ DownloadUtils .pause (fileData .getRequestTag ());
137
137
}
138
138
}
139
139
@@ -143,8 +143,8 @@ public void downTaskPause1(View view) {
143
143
* @param view
144
144
*/
145
145
public void downTaskPause2 (View view ) {
146
- if (fileCacheData2 != null ) {
147
- DownloadUtils .pause (fileCacheData2 .getRequestTag ());
146
+ if (fileData2 != null ) {
147
+ DownloadUtils .pause (fileData2 .getRequestTag ());
148
148
}
149
149
}
150
150
@@ -154,8 +154,8 @@ public void downTaskPause2(View view) {
154
154
* @param view
155
155
*/
156
156
public void downTaskPause3 (View view ) {
157
- if (fileCacheData3 != null ) {
158
- DownloadUtils .pause (fileCacheData3 .getRequestTag ());
157
+ if (fileData3 != null ) {
158
+ DownloadUtils .pause (fileData3 .getRequestTag ());
159
159
}
160
160
}
161
161
@@ -165,8 +165,8 @@ public void downTaskPause3(View view) {
165
165
* @param view
166
166
*/
167
167
public void downTaskPause4 (View view ) {
168
- if (fileCacheData4 != null ) {
169
- DownloadUtils .pause (fileCacheData4 .getRequestTag ());
168
+ if (fileData4 != null ) {
169
+ DownloadUtils .pause (fileData4 .getRequestTag ());
170
170
}
171
171
}
172
172
@@ -188,7 +188,7 @@ public void downloadStop(View view) {
188
188
DownloadUtils .cancelAll ();
189
189
}
190
190
191
- FileCacheData fileCacheData = null ;
191
+ FileData fileData = null ;
192
192
193
193
//文件下载
194
194
public void downloadFile1 (View view ) {
@@ -197,69 +197,69 @@ public void downloadFile1(View view) {
197
197
return ;
198
198
}
199
199
//开启任务下载----------------------这里可执行多个任务 重复执行即可---------
200
- fileCacheData = new FileCacheData ();
201
- fileCacheData .setUrl (downloadUrl1 );
202
- fileCacheData .setFileName (fileName1 );
203
- fileCacheData .setRequestTag (downloadUrl1 );
204
- fileCacheData .setFilePath (saveRootPath + fileName1 );
205
- addDownloadTask (fileCacheData );
200
+ fileData = new FileData ();
201
+ fileData .setUrl (downloadUrl1 );
202
+ fileData .setFileName (fileName1 );
203
+ fileData .setRequestTag (downloadUrl1 );
204
+ fileData .setFilePath (saveRootPath + fileName1 );
205
+ addDownloadTask (fileData );
206
206
FileUtils .writeFileData (saveCachePath , "_" + saveRootPath + fileName1 , false );
207
207
tvTime1 .setText (TimeUtils .getTodayDateHms ("yyyy-MM-dd HH:mm:ss" ));
208
208
//-----------------------------------------------------------
209
209
}
210
210
211
- FileCacheData fileCacheData2 = null ;
211
+ FileData fileData2 = null ;
212
212
213
213
//文件下载
214
214
public void downloadFile2 (View view ) {
215
215
if (NetUtils .getNetWorkType () == NetUtils .NETWORK_NO ) {
216
216
ToastUtils .error ("当前无网络连接!" );
217
217
return ;
218
218
}
219
- fileCacheData2 = new FileCacheData ();
220
- fileCacheData2 .setUrl (downloadUrl2 );
221
- fileCacheData2 .setFileName (fileName2 );
222
- fileCacheData2 .setRequestTag (downloadUrl2 );
223
- fileCacheData2 .setFilePath (saveRootPath + fileName2 );
224
- addDownloadTask (fileCacheData2 );
219
+ fileData2 = new FileData ();
220
+ fileData2 .setUrl (downloadUrl2 );
221
+ fileData2 .setFileName (fileName2 );
222
+ fileData2 .setRequestTag (downloadUrl2 );
223
+ fileData2 .setFilePath (saveRootPath + fileName2 );
224
+ addDownloadTask (fileData2 );
225
225
FileUtils .writeFileData (saveCachePath , "_" + saveRootPath + fileName2 , false );
226
226
tvTime2 .setText (TimeUtils .getTodayDateHms ("yyyy-MM-dd HH:mm:ss" ));
227
227
//-----------------------------------------------------------
228
228
}
229
229
230
- FileCacheData fileCacheData3 = null ;
230
+ FileData fileData3 = null ;
231
231
232
232
//文件下载
233
233
public void downloadFile3 (View view ) {
234
234
if (NetUtils .getNetWorkType () == NetUtils .NETWORK_NO ) {
235
235
ToastUtils .error ("当前无网络连接!" );
236
236
return ;
237
237
}
238
- fileCacheData3 = new FileCacheData ();
239
- fileCacheData3 .setUrl (downloadUrl3 );
240
- fileCacheData3 .setFileName (fileName3 );
241
- fileCacheData3 .setRequestTag (downloadUrl3 );
242
- fileCacheData3 .setFilePath (saveRootPath + fileName3 );
243
- addDownloadTask (fileCacheData3 );
238
+ fileData3 = new FileData ();
239
+ fileData3 .setUrl (downloadUrl3 );
240
+ fileData3 .setFileName (fileName3 );
241
+ fileData3 .setRequestTag (downloadUrl3 );
242
+ fileData3 .setFilePath (saveRootPath + fileName3 );
243
+ addDownloadTask (fileData3 );
244
244
FileUtils .writeFileData (saveCachePath , "_" + saveRootPath + fileName3 , false );
245
245
tvTime3 .setText (TimeUtils .getTodayDateHms ("yyyy-MM-dd HH:mm:ss" ));
246
246
//-----------------------------------------------------------
247
247
}
248
248
249
- FileCacheData fileCacheData4 = null ;
249
+ FileData fileData4 = null ;
250
250
251
251
//文件下载
252
252
public void downloadFile4 (View view ) {
253
253
if (NetUtils .getNetWorkType () == NetUtils .NETWORK_NO ) {
254
254
ToastUtils .error ("当前无网络连接!" );
255
255
return ;
256
256
}
257
- fileCacheData4 = new FileCacheData ();
258
- fileCacheData4 .setUrl (downloadUrl4 );
259
- fileCacheData4 .setFileName (fileName4 );
260
- fileCacheData4 .setRequestTag (downloadUrl4 );
261
- fileCacheData4 .setFilePath (saveRootPath + fileName4 );
262
- addDownloadTask (fileCacheData4 );
257
+ fileData4 = new FileData ();
258
+ fileData4 .setUrl (downloadUrl4 );
259
+ fileData4 .setFileName (fileName4 );
260
+ fileData4 .setRequestTag (downloadUrl4 );
261
+ fileData4 .setFilePath (saveRootPath + fileName4 );
262
+ addDownloadTask (fileData4 );
263
263
FileUtils .writeFileData (saveCachePath , "_" + saveRootPath + fileName4 , false );
264
264
tvTime4 .setText (TimeUtils .getTodayDateHms ("yyyy-MM-dd HH:mm:ss" ));
265
265
//-----------------------------------------------------------
@@ -268,19 +268,19 @@ public void downloadFile4(View view) {
268
268
/**
269
269
* 添加下载任务
270
270
*
271
- * @param fileCacheData
271
+ * @param fileData
272
272
*/
273
- public void addDownloadTask (FileCacheData fileCacheData ) {
274
- DownloadUtils .addStartTask (fileCacheData );
273
+ public void addDownloadTask (FileData fileData ) {
274
+ DownloadUtils .addStartTask (fileData );
275
275
}
276
276
277
277
//下载进度 可根据设置的requestTag来区分属于哪个下载进度 fileCacheData.getRequestTag()
278
278
IDownloadCallback downloadCallBack = new IDownloadCallback () {
279
279
@ Override
280
- public void downloadProgress (FileCacheData fileCacheData , int percent ) {
281
- KLog .d (TAG , "download:>filename=" + fileCacheData .getFileName () + ",percent=" + percent + ",current=" + fileCacheData .getCurrent ());
280
+ public void downloadProgress (FileData fileData , int percent ) {
281
+ KLog .d (TAG , "download:>filename=" + fileData .getFileName () + ",percent=" + percent + ",current=" + fileData .getCurrent ());
282
282
Message message1 = handler .obtainMessage ();
283
- message1 .obj = fileCacheData ;
283
+ message1 .obj = fileData ;
284
284
message1 .arg1 = percent ;
285
285
handler .sendMessage (message1 );
286
286
}
@@ -292,28 +292,28 @@ public void error(Throwable e) {
292
292
}
293
293
294
294
@ Override
295
- public void taskExist (FileCacheData fileCacheData ) {
295
+ public void taskExist (FileData fileData ) {
296
296
ToastUtils .warning ("任务存在" );
297
297
}
298
298
299
299
@ Override
300
- public void allDownloadComplete (List <FileCacheData > fileCacheDataList ) {
301
- for (int i = 0 ; i < fileCacheDataList .size (); i ++) {
302
- KLog .d (TAG , "allDownloadComplete:>requestTag=" + fileCacheDataList .get (i ).getRequestTag () + "" + fileCacheDataList .get (i ).getFileName () + "," + fileCacheDataList .get (i ).getCurrent () + "," + fileCacheDataList .get (i ).getTotal ());
300
+ public void allDownloadComplete (List <FileData > fileDataList ) {
301
+ for (int i = 0 ; i < fileDataList .size (); i ++) {
302
+ KLog .d (TAG , "allDownloadComplete:>requestTag=" + fileDataList .get (i ).getRequestTag () + "" + fileDataList .get (i ).getFileName () + "," + fileDataList .get (i ).getCurrent () + "," + fileDataList .get (i ).getTotal ());
303
303
}
304
304
}
305
305
306
306
@ Override
307
- public void downloadStatus (FileCacheData fileCacheData , int downloadStatus ) {
308
- KLog .d (TAG , "downloadStatus:>requestTag =" + fileCacheData .getRequestTag () + ",status=" + downloadStatus );
307
+ public void downloadStatus (FileData fileData , int downloadStatus ) {
308
+ KLog .d (TAG , "downloadStatus:>requestTag =" + fileData .getRequestTag () + ",status=" + downloadStatus );
309
309
}
310
310
};
311
311
Handler handler = new Handler () {
312
312
@ Override
313
313
public void handleMessage (Message msg ) {
314
314
super .handleMessage (msg );
315
- FileCacheData fileCacheData = (FileCacheData ) msg .obj ;
316
- switch (fileCacheData .getRequestTag ()) {
315
+ FileData fileData = (FileData ) msg .obj ;
316
+ switch (fileData .getRequestTag ()) {
317
317
case downloadUrl1 :
318
318
pbProgressbar1 .setProgress (msg .arg1 );
319
319
tvResult1 .setText ("update1.zip >>> " + msg .arg1 + "%" );
0 commit comments