Move ongoing match fetching to the background thread
This commit is contained in:
@@ -109,12 +109,24 @@ public class MainMenuActivity extends BaseActivity {
|
|||||||
getString(R.string.pref_game_mode_501_value));
|
getString(R.string.pref_game_mode_501_value));
|
||||||
quickStartBtn.setSubText(defaultGameMode);
|
quickStartBtn.setSubText(defaultGameMode);
|
||||||
quickStartBtn.setOnClickListener(v -> quickStart());
|
quickStartBtn.setOnClickListener(v -> quickStart());
|
||||||
|
mOngoingMatch = null; // Reset before re-checking
|
||||||
|
new Thread(() -> {
|
||||||
final List<Match> ongoingMatches = mDatabaseHelper.getOngoingMatches();
|
final List<Match> ongoingMatches = mDatabaseHelper.getOngoingMatches();
|
||||||
if (ongoingMatches != null && !ongoingMatches.isEmpty()) {
|
if (ongoingMatches != null && !ongoingMatches.isEmpty()) {
|
||||||
mOngoingMatch = ongoingMatches.get(0);
|
mOngoingMatch = ongoingMatches.get(0);
|
||||||
}
|
}
|
||||||
if (mOngoingMatch != null) {
|
if (mOngoingMatch != null) {
|
||||||
Log.d(TAG, "onCreate: Found ongoing match [" + mOngoingMatch + "]");
|
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, "onResume: Found ongoing match [" + mOngoingMatch + "]");
|
||||||
quickStartBtn.setSubText("Continue match with " + mOngoingMatch.gameMode + " score");
|
quickStartBtn.setSubText("Continue match with " + mOngoingMatch.gameMode + " score");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user