Skip to content

Commit

Permalink
user rating in float now
Browse files Browse the repository at this point in the history
  • Loading branch information
armaanbadhan committed Feb 20, 2023
1 parent 48d910c commit 19741ad
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.google.firebase.ktx.Firebase
import com.pec_acm.moviedroid.firebase.User
import kotlinx.coroutines.launch


class ProfileViewModel: ViewModel() {
private var databaseReference = Firebase.database.reference
private var userReference = databaseReference.child("Users")
Expand Down Expand Up @@ -49,23 +48,23 @@ class ProfileViewModel: ViewModel() {
{
overallRating.value = buildString {
append("Overall Rating:\n")
append((movieRate + tvRate) / (movieCount + tvCount))
append(String.format("%.2f", (movieRate + tvRate).toFloat() / (movieCount + tvCount)))
append("/10")
}
}
if (tvCount != 0)
{
tvRating.value = buildString {
append("TV Shows Rating:\n")
append((tvRate / tvCount))
append(String.format("%.2f", tvRate.toFloat() / tvCount))
append("/10")
}
}
if (movieCount != 0)
{
movieRating.value = buildString {
append("Movie Rating:\n")
append(movieRate / movieCount)
append(String.format("%.2f", movieRate.toFloat() / movieCount))
append("/10")
}
}
Expand Down

0 comments on commit 19741ad

Please sign in to comment.