Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions sys/android/forkfront/src/com/tbd/forkfront/ForkFront.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public String decode(byte[] bytes) {
};

nhState = new NH_State(this, decoder);
new UpdateAssets(this, onAssetsReady).execute((Void[])null);
new UpdateAssets(this, assetsReadyFor(nhState)).execute((Void[])null);
}
else
{
Expand Down Expand Up @@ -195,20 +195,29 @@ public void onConfigurationChanged(Configuration newConfig)
}

// ____________________________________________________________________________________
private UpdateAssets.Listener onAssetsReady = new UpdateAssets.Listener()
// If the activity is recreated while the assets are being copied, the old copy finishes
// after a new NH_State has replaced this one. Only the copy started for the current state
// may start the game, or the game thread would be started twice.
private UpdateAssets.Listener assetsReadyFor(final NH_State state)
{
@Override
public void onAssetsReady(File path)
return new UpdateAssets.Listener()
{
// Create save directory if it doesn't exist
File nhSaveDir = new File(path, "save");
if(!nhSaveDir.exists())
nhSaveDir.mkdir();
@Override
public void onAssetsReady(File path)
{
if(state != nhState)
return;

PreferenceManager.setDefaultValues(ForkFront.this, R.xml.preferences, false);
nhState.startNetHack(path.getAbsolutePath());
}
};
// Create save directory if it doesn't exist
File nhSaveDir = new File(path, "save");
if(!nhSaveDir.exists())
nhSaveDir.mkdir();

PreferenceManager.setDefaultValues(ForkFront.this, R.xml.preferences, false);
state.startNetHack(path.getAbsolutePath());
}
};
}

// ____________________________________________________________________________________
@Override
Expand Down
Loading