Skip to content

Commit

Permalink
Fix issue #9
Browse files Browse the repository at this point in the history
  • Loading branch information
HBiSoft committed Dec 9, 2019
1 parent 9f5a8a2 commit 09a0a43
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
10 changes: 8 additions & 2 deletions pickit/src/main/java/com/hbisoft/pickit/DownloadAsyncTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ protected String doInBackground(Uri... params) {
try {
try {
if (returnCursor != null && returnCursor.moveToFirst()){
int sizeIndex = returnCursor.getColumnIndex(OpenableColumns.SIZE);
size = (int) returnCursor.getLong(sizeIndex);
if (mUri.getScheme() != null)
if (mUri.getScheme().equals("content")) {
int sizeIndex = returnCursor.getColumnIndex(OpenableColumns.SIZE);
size = (int) returnCursor.getLong(sizeIndex);
}else if (mUri.getScheme().equals("file")) {
File ff = new File(mUri.getPath());
size = (int) ff.length();
}
}
}
finally {
Expand Down
14 changes: 8 additions & 6 deletions pickit/src/main/java/com/hbisoft/pickit/PickiT.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ public void getPath(Uri uri, int APILevel){
//We first check if it was called before, avoiding multiple calls
if (!unknownProviderCalledBefore) {
unknownProviderCalledBefore = true;
//Then we check if the _data colomn returned null
if (Utils.errorReason() != null && Utils.errorReason().equals("dataReturnedNull")) {
isFromUnknownProvider = true;
//Copy the file to the temporary folder
downloadFile(uri, getFileName(uri));
return;
if (uri.getScheme() != null && uri.getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
//Then we check if the _data colomn returned null
if (Utils.errorReason() != null && Utils.errorReason().equals("dataReturnedNull")) {
isFromUnknownProvider = true;
//Copy the file to the temporary folder
downloadFile(uri, getFileName(uri));
return;
}
}
}
//Else an error occurred, get/set the reason for the error
Expand Down

0 comments on commit 09a0a43

Please sign in to comment.