Kaynağa Gözat

Changed books count type from String to Int

Vadik Sirekanyan 5 yıl önce
ebeveyn
işleme
dee1306664

+ 1 - 1
app/src/main/java/com/sirekanyan/knigopis/feature/users/UserViewHolder.kt

@@ -31,7 +31,7 @@ class UserViewHolder(
     override fun onBind(position: Int, model: UserModel) {
         userImage.setCircleImage(model.image)
         userNickname.text = model.name
-        totalBooksCount.text = model.booksCount
+        totalBooksCount.text = model.booksCount?.toString()
         newBooksCount.text = model.newBooksCountFormatted
     }
 

+ 3 - 3
app/src/main/java/com/sirekanyan/knigopis/model/UserModel.kt

@@ -7,13 +7,13 @@ class UserModel(
     val id: String,
     val name: String,
     val image: String?,
-    val booksCount: String?,
-    val newBooksCount: String?,
+    val booksCount: Int?,
+    val newBooksCount: Int?,
     val profiles: List<String>
 ) {
 
     val newBooksCountFormatted: SpannableString?
-        get() = newBooksCount?.let { count ->
+        get() = newBooksCount?.let { "+$it" }?.let { count ->
             SpannableString(count).also {
                 it.setSpan(SuperscriptSpan(), 0, count.length, 0)
             }

+ 2 - 2
app/src/main/java/com/sirekanyan/knigopis/model/mappers.kt

@@ -37,8 +37,8 @@ fun Subscription.toUserModel() =
         subUser.id,
         subUser.name,
         createUserImageUrl(subUser.id),
-        subUser.booksCount.takeIf { it > 0 }?.toString(),
-        newBooksCount.takeIf { it > 0 }?.let { "+$it" },
+        subUser.booksCount.takeIf { it > 0 },
+        newBooksCount.takeIf { it > 0 },
         subUser.profiles
     )