Move ongoing match fetching to the background thread

This commit is contained in:
Alexander Doerflinger
2026-02-18 13:32:21 +01:00
parent 847b8e1d7e
commit 4631f357c0

View File

@@ -109,12 +109,24 @@ public class MainMenuActivity extends BaseActivity {
getString(R.string.pref_game_mode_501_value));
quickStartBtn.setSubText(defaultGameMode);
quickStartBtn.setOnClickListener(v -> quickStart());
mOngoingMatch = null; // Reset before re-checking
new Thread(() -> {
final List<Match> ongoingMatches = mDatabaseHelper.getOngoingMatches();
if (ongoingMatches != null && !ongoingMatches.isEmpty()) {
mOngoingMatch = ongoingMatches.get(0);
}
if (mOngoingMatch != null) {
Log.d(TAG, "onResume: Found ongoing match [" + mOngoingMatch + "]");
runOnUiThread(
() -> quickStartBtn.setSubText("Continue match with " + mOngoingMatch.gameMode + " score"));
}
}).start();
final List<Match> ongoingMatches = mDatabaseHelper.getOngoingMatches();
if (ongoingMatches != null && !ongoingMatches.isEmpty()) {
mOngoingMatch = ongoingMatches.get(0);
}
if (mOngoingMatch != null) {
Log.d(TAG, "onCreate: Found ongoing match [" + mOngoingMatch + "]");
Log.d(TAG, "onResume: Found ongoing match [" + mOngoingMatch + "]");
quickStartBtn.setSubText("Continue match with " + mOngoingMatch.gameMode + " score");
}
}