use string.equals(ignoreCase=true) instead of regex

This commit is contained in:
adrienmalin
2018-12-14 20:46:27 +01:00
parent 222c414cf2
commit 4bb1ff5b42
6 changed files with 11 additions and 14 deletions

View File

@ -59,8 +59,8 @@ class MatchActivity : AppCompatActivity() {
val player1Name = getStringExtra("player1Name")
val player2Name = getStringExtra("player2Name")
players = listOf(
Player(player1Name, 0, Pattern.compile(getString(R.string.pattern, player1Name))),
Player(player2Name, 0, Pattern.compile(getString(R.string.pattern, player2Name)))
Player(player1Name, 0),
Player(player2Name, 0)
)
serviceSide = getIntExtra("starterId", 0)
relaunchSide = when(serviceSide) {

View File

@ -1,9 +1,6 @@
package adrienmalin.pingpoints
import java.util.regex.Pattern
data class Player (
var name: String,
var score: Int,
var pattern: Pattern? = null
var score: Int
)

View File

@ -57,7 +57,7 @@ class SttDialog : DialogFragment() {
matchModel?.apply {
for (result in results) {
for (player in players) {
if (player.pattern?.matcher(result)?.find() == true) {
if (getString(R.string.pattern, player.name).equals(result, ignoreCase=true)) {
dismiss()
updateScore(player)
updateUI()
@ -97,8 +97,8 @@ class SttDialog : DialogFragment() {
matchModel?.apply {
view.findViewById<TextView>(R.id.sttHintTextView).text = getString(
R.string.STT_hint,
players[0].name,
players[1].name
getString(R.string.pattern, players[0].name),
getString(R.string.pattern, players[1].name)
)
sttIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH).apply {
putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)