@@ -480,23 +480,24 @@ class SportFragment : DaggerAndroidXFragment(R.layout.fragment_sport) {
480
480
}
481
481
482
482
private fun applyWorldRugbyMatchToInput (worldRugbyMatch : WorldRugbyMatch ) {
483
- homeTeamId = worldRugbyMatch.firstTeamId
484
- homeTeamName = worldRugbyMatch.firstTeamName
485
- homeTeamAbbreviation = worldRugbyMatch.firstTeamAbbreviation!!
483
+ val switched = worldRugbyMatch.secondTeamName == worldRugbyMatch.venueName
484
+ homeTeamId = if (! switched) worldRugbyMatch.firstTeamId else worldRugbyMatch.secondTeamId
485
+ homeTeamName = if (! switched) worldRugbyMatch.firstTeamName else worldRugbyMatch.secondTeamName
486
+ homeTeamAbbreviation = if (! switched) worldRugbyMatch.firstTeamAbbreviation!! else worldRugbyMatch.secondTeamAbbreviation!!
486
487
val homeTeam = EmojiCompat .get().process(getString(R .string.menu_item_team,
487
- FlagUtils .getFlagEmojiForTeamAbbreviation(worldRugbyMatch.firstTeamAbbreviation !! ), homeTeamName))
488
+ FlagUtils .getFlagEmojiForTeamAbbreviation(homeTeamAbbreviation !! ), homeTeamName))
488
489
matchPredictionInputView.homeTeamText = homeTeam
489
- awayTeamId = worldRugbyMatch.secondTeamId
490
- awayTeamName = worldRugbyMatch.secondTeamName
491
- awayTeamAbbreviation = worldRugbyMatch.secondTeamAbbreviation!!
490
+ awayTeamId = if ( ! switched) worldRugbyMatch.secondTeamId else worldRugbyMatch.firstTeamId
491
+ awayTeamName = if ( ! switched) worldRugbyMatch.secondTeamName else worldRugbyMatch.firstTeamName
492
+ awayTeamAbbreviation = if ( ! switched) worldRugbyMatch.secondTeamAbbreviation!! else worldRugbyMatch.firstTeamAbbreviation !!
492
493
val awayTeam = EmojiCompat .get().process(getString(R .string.menu_item_team,
493
- FlagUtils .getFlagEmojiForTeamAbbreviation(worldRugbyMatch.secondTeamAbbreviation !! ), awayTeamName))
494
+ FlagUtils .getFlagEmojiForTeamAbbreviation(awayTeamAbbreviation !! ), awayTeamName))
494
495
matchPredictionInputView.awayTeamText = awayTeam
495
496
when (worldRugbyMatch.status) {
496
497
MatchStatus .UNPLAYED -> matchPredictionInputView.clearMatchPredictionPointsInput()
497
498
else -> {
498
- matchPredictionInputView.homePointsText = worldRugbyMatch.firstTeamScore
499
- matchPredictionInputView.awayPointsText = worldRugbyMatch.secondTeamScore
499
+ matchPredictionInputView.homePointsText = if ( ! switched) worldRugbyMatch.firstTeamScore else worldRugbyMatch.secondTeamScore
500
+ matchPredictionInputView.awayPointsText = if ( ! switched) worldRugbyMatch.secondTeamScore else worldRugbyMatch.firstTeamScore
500
501
}
501
502
}
502
503
matchPredictionInputView.nhaChecked = worldRugbyMatch.venueCountry?.let { venueCountry ->
0 commit comments