Skip to content

Commit

Permalink
Extract color values to their own variable
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarX committed Jun 11, 2024
1 parent 0e47c2e commit 1ba8e21
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ class EditorSampleFragment : Fragment() {
}
focusEditorButton.setOnClickListener { editor.requestFocusAndOpenKeyboard() }

textColorRed.setOnClickListener { editor.setTextColor(Color.parseColor("#FF0000")) }
textColorBlue.setOnClickListener { editor.setTextColor(Color.parseColor("#0000FF")) }
textBackgroundColorRed.setOnClickListener { editor.setTextBackgroundColor(Color.parseColor("#FF0000")) }
textBackgroundColorBlue.setOnClickListener { editor.setTextBackgroundColor(Color.parseColor("#0000FF")) }
textColorRed.setOnClickListener { editor.setTextColor(RED) }
textColorBlue.setOnClickListener { editor.setTextColor(BLUE) }
textBackgroundColorRed.setOnClickListener { editor.setTextBackgroundColor(RED) }
textBackgroundColorBlue.setOnClickListener { editor.setTextBackgroundColor(BLUE) }
}

private fun observeEditorStatusUpdates() = with(binding) {
Expand Down Expand Up @@ -140,4 +140,9 @@ class EditorSampleFragment : Fragment() {
dialog.show()
}
}

companion object {
private val RED = Color.parseColor("#FF0000")
private val BLUE = Color.parseColor("#0000FF")
}
}

0 comments on commit 1ba8e21

Please sign in to comment.