-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from Entreco/feature/41-quick-revanche
Feature/41 quick revanche
- Loading branch information
Showing
46 changed files
with
934 additions
and
112 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
android/DartsScorecard/app/src/main/java/nl/entreco/dartsscorecard/base/DialogHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package nl.entreco.dartsscorecard.base | ||
|
||
import android.support.v7.app.AlertDialog | ||
import nl.entreco.dartsscorecard.R | ||
import nl.entreco.domain.model.players.Team | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by entreco on 20/02/2018. | ||
*/ | ||
class DialogHelper @Inject constructor(private val builder: AlertDialog.Builder) { | ||
|
||
fun revanche(previousIndex: Int, teams: Array<Team>, select: (Int) -> Unit) { | ||
|
||
if (onlyOneTeam(teams)) { | ||
select(0) | ||
} else if (moreThanOneTeam(teams)) { | ||
var selectedIndex = previousIndex | ||
builder | ||
.setTitle(R.string.select_starting_team) | ||
.setSingleChoiceItems(teams.map { it.toString() }.toTypedArray(), previousIndex, { _, which -> | ||
selectedIndex = which | ||
}) | ||
.setPositiveButton(android.R.string.ok, { dialog, _ -> | ||
select(selectedIndex) | ||
dialog.dismiss() | ||
}) | ||
.setNegativeButton(R.string.cancel, { dialog, _ -> | ||
dialog.dismiss() | ||
}) | ||
.create() | ||
.show() | ||
} | ||
} | ||
|
||
private fun onlyOneTeam(teams: Array<Team>) = teams.size == 1 | ||
private fun moreThanOneTeam(teams: Array<Team>) = teams.size > 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12
android/DartsScorecard/app/src/main/java/nl/entreco/dartsscorecard/di/play/Play01Module.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
package nl.entreco.dartsscorecard.di.play | ||
|
||
import android.content.Context | ||
import android.support.v7.app.AlertDialog | ||
import dagger.Module | ||
import dagger.Provides | ||
|
||
/** | ||
* Created by Entreco on 14/11/2017. | ||
*/ | ||
@Module | ||
class Play01Module | ||
class Play01Module { | ||
|
||
@Provides | ||
@Play01Scope | ||
fun provideAlertDialogBuilder(context: Context): AlertDialog.Builder { | ||
return AlertDialog.Builder(context) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.