Skip to content

Commit

Permalink
Do not block the main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
lvonasek committed Sep 4, 2023
1 parent 43d0206 commit 79b0e86
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions app/src/main/java/com/lvonasek/preyvr/GLES3JNIActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in

public void create() {

//Init screen
mView = new SurfaceView( this );
setContentView( mView );
mView.getHolder().addCallback( this );

//Base game
base.mkdirs();
copy_asset(base.getAbsolutePath(), "vr_support.pk4", true);
Expand All @@ -236,14 +231,25 @@ public void create() {
copy_asset(base.getAbsolutePath(), demoLayout, true);
}

//Unpack data
if (has_files(base, DATA_FULL)) {
if (!has_files(base, DATA_MODS)) {
unpack_data(DATA_MODS);
new Thread(() -> {
//Unpack data
if (has_files(base, DATA_FULL)) {
if (!has_files(base, DATA_MODS)) {
unpack_data(DATA_MODS);
}
} else if (!has_files(base, DATA_DEMO)) {
unpack_data(DATA_DEMO);
}
} else if (!has_files(base, DATA_DEMO)) {
unpack_data(DATA_DEMO);
}
runOnUiThread(this::startGame);
}).start();
}

public void startGame() {

//Init screen
mView = new SurfaceView( this );
setContentView( mView );
mView.getHolder().addCallback( this );

try {
setenv("USER_FILES", root.getAbsolutePath(), true);
Expand Down

0 comments on commit 79b0e86

Please sign in to comment.