Skip to content

Commit

Permalink
Clean code using constants and by removing useless new lines
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarX committed Jun 13, 2024
1 parent 0952e96 commit 31fe849
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class RichHtmlEditorWebView @JvmOverloads constructor(
fun toggleUnderline() = jsBridge.toggleUnderline()
fun removeFormat() = jsBridge.removeFormat()
fun setTextColor(@ColorInt color: Int) = jsBridge.setTextColor(JsColor(color))

fun setTextBackgroundColor(@ColorInt color: Int) = jsBridge.setTextBackgroundColor(JsColor(color))
fun setFontSize(@IntRange(from = 1, to = 7) fontSize: Int) = jsBridge.setFontSize(fontSize)
fun createLink(displayText: String?, url: String) = jsBridge.createLink(displayText, url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ class EditorSampleFragment : Fragment() {
textBackgroundColorRed.setOnClickListener { editor.setTextBackgroundColor(RED) }
textBackgroundColorBlue.setOnClickListener { editor.setTextBackgroundColor(BLUE) }

fontSmallButton.setOnClickListener { editor.setFontSize(2) }
fontMediumButton.setOnClickListener { editor.setFontSize(4) }
fontBigButton.setOnClickListener { editor.setFontSize(6) }
fontSmallButton.setOnClickListener { editor.setFontSize(SMALL_FONT_SIZE) }
fontMediumButton.setOnClickListener { editor.setFontSize(MEDIUM_FONT_SIZE) }
fontBigButton.setOnClickListener { editor.setFontSize(BIG_FONT_SIZE) }
}

private fun observeEditorStatusUpdates() = with(binding) {
Expand Down Expand Up @@ -148,5 +148,9 @@ class EditorSampleFragment : Fragment() {
companion object {
private val RED = Color.parseColor("#FF0000")
private val BLUE = Color.parseColor("#0000FF")

private val SMALL_FONT_SIZE = 2
private val MEDIUM_FONT_SIZE = 4
private val BIG_FONT_SIZE = 6
}
}

0 comments on commit 31fe849

Please sign in to comment.