Skip to content

Commit

Permalink
thread safe run
Browse files Browse the repository at this point in the history
  • Loading branch information
scenemax3d committed Jul 21, 2024
1 parent d34c9e6 commit 5398afe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/main/java/com/scenemaxeng/FullscreenGameActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,17 @@ private void startGame() {
showJmeProjectorFragment();
File targetFile = new File(this.targetScriptPath);
if(targetFile.exists()) {
new Handler().postDelayed(new Runnable() {
runOnUiThread(new Runnable() {
@Override
public void run() {

String code = Util.readFile(targetFile);
code=code.replaceFirst("^canvas\\.size\\s+((?<val1>\\d+),(?<val2>\\d+))","");;
code = applyMacros(code);
String workingFolder = targetFile.getParentFile().getAbsolutePath();
getJmeFragment().runScript(code, workingFolder);
app = (SceneMaxApp) getJmeFragment().getJmeApplication();
}
},500);
});

}
}
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/scenemaxeng/common/types/AssetsMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,9 @@ private JSONObject getAssetsResourcesFolderIndex(String path) {

try {
String data = loadFileFromAssets(path);
return new JSONObject(data);
if(data != null && data.length() > 0) {
return new JSONObject(data);
}

} catch (Exception e) {
e.printStackTrace();
Expand All @@ -432,8 +434,10 @@ private JSONObject getResourcesFolderIndex(String path) {
try {
File f = new File(path);
if(f.exists()) {
String json = Util.readFile(f);
return new JSONObject(json);
String data = Util.readFile(f);
if(data != null && data.length() > 0) {
return new JSONObject(data);
}
}
} catch (Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit 5398afe

Please sign in to comment.