Skip to content

Commit

Permalink
Add methods without listener
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed Nov 14, 2024
1 parent 0a00a50 commit ac42079
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ public boolean isAssetLoaded(FileType fileType, String path) {
return fileHandle.exists();
}

@Override
public void loadAsset(String path, AssetType assetType, FileType fileType) {
loadAsset(true, path, assetType, fileType, null, false);
}

@Override
public void loadAsset(String path, AssetType assetType, FileType fileType, AssetLoaderListener<Blob> listener) {
loadAsset(true, path, assetType, fileType, listener, false);
Expand All @@ -218,6 +223,21 @@ public void loadAsset(String path, AssetType assetType, FileType fileType, Asset
loadAsset(true, path, assetType, fileType, listener, overwrite);
}

@Override
public void loadScript(String path) {
assetDownloader.loadScript(true, getScriptUrl() + path, null);
}

@Override
public void loadScript(String path, AssetLoaderListener<String> listener) {
assetDownloader.loadScript(true, getScriptUrl() + path, listener);
}

@Override
public int getQueue() {
return assetDownloader.getQueue();
}

private void loadAsset(boolean async, String path, AssetType assetType, FileType fileType, AssetLoaderListener<Blob> listener, boolean overwrite) {
String path1 = fixPath(path);

Expand Down Expand Up @@ -281,16 +301,6 @@ public void onSuccess(String url, Blob result) {
});
}

@Override
public void loadScript(String path, AssetLoaderListener<String> listener) {
assetDownloader.loadScript(true, getScriptUrl() + path, listener);
}

@Override
public int getQueue() {
return assetDownloader.getQueue();
}

private String fixPath(String path1) {
path1 = path1.trim().replace("\\", "/");
if(path1.startsWith("/")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public interface AssetLoader {

boolean isAssetLoaded(FileType fileType, String path);

/**
* Load asset and add to FileHandle system. Skip downloading if file already exists
*/
void loadAsset(String path, AssetType assetType, FileType fileType);

/**
* Load asset and add to FileHandle system. Skip downloading if file already exists
*/
Expand All @@ -28,6 +33,11 @@ public interface AssetLoader {
*/
void loadAsset(String path, AssetType assetType, FileType fileType, AssetLoaderListener<Blob> listener, boolean overwrite);

/**
* Load script and attach to html document
*/
void loadScript(String path);

/**
* Load script and attach to html document
*/
Expand Down

0 comments on commit ac42079

Please sign in to comment.