Skip to content

Commit

Permalink
[TIMOB-19194] Android: Intent putExtraUri accepts a String array
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashraf committed Nov 23, 2015
1 parent adebf56 commit b5d18f7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -222,9 +223,27 @@ public int getFlags()
}

@Kroll.method
public void putExtraUri(String key, String uri)
public void putExtraUri(String key, Object value)
{
intent.putExtra(key, Uri.parse(uri));
if (value == null) {
return;
}

if (value instanceof String) {
intent.putExtra(key, Uri.parse((String) value));
} else if (value instanceof Object[]) {
try {
Object[] objVal = (Object[]) value;
String[] stringArray = Arrays.copyOf(objVal, objVal.length, String[].class);
ArrayList<Uri> imageUris = new ArrayList<Uri>();
for(String s: stringArray) {
imageUris.add(Uri.parse(s));
}
intent.putParcelableArrayListExtra(key, imageUris);
} catch (Exception ex) {
Log.e(TAG, "Error unimplemented put conversion ", ex.getMessage());
}
}
}

@Kroll.method
Expand Down
4 changes: 2 additions & 2 deletions apidoc/Titanium/Android/Intent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ methods:
type: String

- name: value
summary: The URI, as a string.
type: String
summary: The URI, as a string or a string array.
type: Object

properties:

Expand Down

0 comments on commit b5d18f7

Please sign in to comment.