Skip to content

Commit

Permalink
feat(android): enable loading of assets outside of the content web as…
Browse files Browse the repository at this point in the history
…set directory (#6301)
  • Loading branch information
carlpoole committed Feb 21, 2023
1 parent 8869d79 commit 364497d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class ProcessedRoute {

private String path;
private boolean isAsset;
private boolean ignoreAssetPath;

public String getPath() {
return path;
Expand All @@ -25,4 +26,12 @@ public boolean isAsset() {
public void setAsset(boolean asset) {
isAsset = asset;
}

public boolean isIgnoreAssetPath() {
return ignoreAssetPath;
}

public void setIgnoreAssetPath(boolean ignoreAssetPath) {
this.ignoreAssetPath = ignoreAssetPath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,12 @@ public InputStream handle(Uri url) {

// Pass path to routeProcessor if present
RouteProcessor routeProcessor = bridge.getRouteProcessor();
boolean ignoreAssetPath = false;
if (routeProcessor != null) {
ProcessedRoute processedRoute = bridge.getRouteProcessor().process("", path);
path = processedRoute.getPath();
isAsset = processedRoute.isAsset();
ignoreAssetPath = processedRoute.isIgnoreAssetPath();
}

try {
Expand All @@ -501,6 +503,8 @@ public InputStream handle(Uri url) {
}

stream = protocolHandler.openFile(path);
} else if (ignoreAssetPath) {
stream = protocolHandler.openAsset(path);
} else {
stream = protocolHandler.openAsset(assetPath + path);
}
Expand Down

0 comments on commit 364497d

Please sign in to comment.