Skip to content

Commit

Permalink
Try parsing URI
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Jan 31, 2024
1 parent 63ffcd0 commit e2f49e8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions android/src/main/java/com/tflite/TfliteModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,18 @@ private static int getResourceId(Context context, String name) {
/** @noinspection unused*/
@DoNotStrip
public static byte[] fetchByteDataFromUrl(String url) throws Exception {
Log.i(NAME, "Loading byte data from URL: " + url + "...");

Uri uri = null;
Integer resourceId = null;
try {
if (url.contains("://")) {
Log.i(NAME, "Parsing URL...");
uri = Uri.parse(url);
Log.i(NAME, "Fetching from URI: " + uri.toString() + "...");
} catch (Exception e) {
Log.e(NAME, "Failed to parse URI! Maybe this is a resourceId instead...", e);
}
if (uri == null || uri.getScheme() == null) {
Log.i(NAME, "Parsed URL: " + uri.toString());
} else {
Log.i(NAME, "Parsing resourceId...");
resourceId = getResourceId(weakContext.get(), url);
Log.i(NAME, "Fetching from resourceId: " + resourceId + "...");
Log.i(NAME, "Parsed resourceId: " + resourceId);
}

if (uri != null) {
Expand Down

0 comments on commit e2f49e8

Please sign in to comment.