Skip to content

Commit

Permalink
Fix issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
HBiSoft committed Sep 9, 2019
1 parent 3eb16d5 commit 4653571
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pickit/src/main/java/com/hbisoft/pickit/DownloadAsyncTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,19 @@ protected void onProgressUpdate(Integer... values) {
@Override
protected String doInBackground(Uri... params) {
File file = null;
int size = -1;

try {
assert returnCursor != null;
int sizeIndex = returnCursor.getColumnIndex(OpenableColumns.SIZE);
returnCursor.moveToFirst();
int size = (int) returnCursor.getLong(sizeIndex);
returnCursor.close();
try {
if (returnCursor != null && returnCursor.moveToFirst()){
int sizeIndex = returnCursor.getColumnIndex(OpenableColumns.SIZE);
size = (int) returnCursor.getLong(sizeIndex);
}
}
finally {
if (returnCursor != null)
returnCursor.close();
}

if (extension == null){
pathPlusName = folder + "/" + filename;
Expand All @@ -88,7 +94,9 @@ protected String doInBackground(Uri... params) {
while ((count = bis.read(data)) != -1) {
if (!isCancelled()) {
total += count;
publishProgress((int) ((total * 100) / size));
if (size != -1) {
publishProgress((int) ((total * 100) / size));
}
fos.write(data, 0, count);
}
}
Expand Down

0 comments on commit 4653571

Please sign in to comment.