Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ class ProfileObservableViewModel : ObservableViewModel() {

@Bindable
fun getPopularity(): Popularity {
return likes.get().let {
when {
it > 9 -> Popularity.STAR
it > 4 -> Popularity.POPULAR
else -> Popularity.NORMAL
}
}
return likes.get().let { decidePopularity(it) }
}
}

Expand All @@ -69,11 +63,9 @@ class ProfileObservableFieldsViewModel : ViewModel() {
fun onLike() {
likes.set(likes.get() + 1)

popularity.set(likes.get().let {
if (it > 9) Popularity.STAR
if (it > 4) Popularity.POPULAR
Popularity.NORMAL
})
popularity.set(
likes.get().let { decidePopularity(it) }
)
}
}

Expand All @@ -86,3 +78,11 @@ enum class Popularity {
private fun ObservableInt.increment() {
set(get() + 1)
}

private fun decidePopularity(likes: Int) : Popularity {
return when {
likes > 9 -> Popularity.STAR
likes > 4 -> Popularity.POPULAR
else -> Popularity.NORMAL
}
}