Skip to content

Commit

Permalink
Merge pull request #1732 from Infomaniak/prepare-code
Browse files Browse the repository at this point in the history
Swap `with(binding) { … }` with `with(threadViewModel) { … }`
  • Loading branch information
LunarX authored Mar 1, 2024
2 parents b1da033 + 082bebe commit 401fbca
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ class ThreadFragment : Fragment() {

private fun setupUi() = with(binding) {

threadSubject.movementMethod = LinkMovementMethod.getInstance()

updateNavigationIcon()
toolbar.setNavigationOnClickListener { twoPaneViewModel.closeThread() }

Expand Down Expand Up @@ -350,18 +352,16 @@ class ThreadFragment : Fragment() {
mainViewModel.toggleLightThemeForMessage.observe(viewLifecycleOwner, threadAdapter::toggleLightMode)
}

private fun observeThreadLive() = with(binding) {
private fun observeThreadLive() = with(threadViewModel) {

threadViewModel.threadLive.observe(viewLifecycleOwner) { thread ->
threadLive.observe(viewLifecycleOwner) { thread ->

if (thread == null) {
twoPaneViewModel.closeThread()
return@observe
}

threadSubject.movementMethod = LinkMovementMethod.getInstance()

iconFavorite.apply {
binding.iconFavorite.apply {
setIconResource(if (thread.isFavorite) R.drawable.ic_star_filled else R.drawable.ic_star)
val color = if (thread.isFavorite) {
context.getColor(R.color.favoriteYellow)
Expand Down

0 comments on commit 401fbca

Please sign in to comment.