Skip to content

Commit

Permalink
Merge pull request #9038 from garymathews/TIMOB-24660_6_1_X
Browse files Browse the repository at this point in the history
[6_1_X][TIMOB-24660] Android: Support loading downloaded images from gallery
  • Loading branch information
ssjsamir committed May 9, 2017
2 parents 7aa0d0e + 28a81fd commit 72f90e9
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@

import org.appcelerator.titanium.TiApplication;

import android.content.ContentUris;
import android.database.Cursor;
import android.net.Uri;
import android.provider.DocumentsContract;
import android.provider.MediaStore;

public class TitaniumBlob extends TiBaseFile
Expand Down Expand Up @@ -51,6 +53,21 @@ protected void init() {
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection, MediaStore.Images.Media._ID + " = ? ", new String[]{id}, null);

if (c.moveToNext()) {
name = c.getString(0);
path = c.getString(1);
}
} finally {
if (c != null) {
c.close();
}
}
} else if (url.startsWith("content://com.android.providers.downloads.documents")) {
try {
String id = DocumentsContract.getDocumentId(Uri.parse(url));
Uri uri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
c = TiApplication.getInstance().getContentResolver().query(uri, projection, null, null, null);

if (c.moveToNext()) {
name = c.getString(0);
path = c.getString(1);
Expand Down

0 comments on commit 72f90e9

Please sign in to comment.