Browse Source

Replaced books/wishes/reviews count with todo/doing/done count on profile screen

Vadik Sirekanyan 7 years ago
parent
commit
f2da50b87b

+ 19 - 16
app/src/main/java/me/vadik/knigopis/profile/ProfileActivity.kt

@@ -30,9 +30,9 @@ class ProfileActivity : AppCompatActivity() {
         super.onCreate(savedInstanceState)
         super.onCreate(savedInstanceState)
         setContentView(R.layout.profile_activity)
         setContentView(R.layout.profile_activity)
         initToolbar(profileToolbar)
         initToolbar(profileToolbar)
-        profileBooksCount.text = getString(R.string.profile_caption_books, 0)
-        profileWishesCount.text = getString(R.string.profile_caption_wishes, 0)
-        profileReviewsCount.text = getString(R.string.profile_caption_reviews, 0)
+        profileTodoCount.text = getString(R.string.profile_caption_todo, 0)
+        profileDoingCount.text = getString(R.string.profile_caption_doing, 0)
+        profileDoneCount.text = getString(R.string.profile_caption_done, 0)
     }
     }
 
 
     override fun onStart() {
     override fun onStart() {
@@ -51,30 +51,33 @@ class ProfileActivity : AppCompatActivity() {
                     )
                     )
                     .transition(DrawableTransitionOptions.withCrossFade())
                     .transition(DrawableTransitionOptions.withCrossFade())
                     .into(profileAvatar)
                     .into(profileAvatar)
-                updateCounters(user.booksCount)
             }, {
             }, {
                 logError("cannot get profile", it)
                 logError("cannot get profile", it)
             })
             })
-    }
-
-    private fun updateCounters(totalBooksCount: Int) {
         api.getFinishedBooks(auth.getAccessToken())
         api.getFinishedBooks(auth.getAccessToken())
             .io2main()
             .io2main()
             .subscribe({ finishedBooks ->
             .subscribe({ finishedBooks ->
-                profileBooksCount.text = getString(
-                    R.string.profile_caption_books,
+                profileDoneCount.text = getString(
+                    R.string.profile_caption_done,
                     finishedBooks.size
                     finishedBooks.size
                 )
                 )
-                profileWishesCount.text = getString(
-                    R.string.profile_caption_wishes,
-                    totalBooksCount - finishedBooks.size
+            }, {
+                logError("cannot check finished books count", it)
+            })
+        api.getPlannedBooks(auth.getAccessToken())
+            .io2main()
+            .subscribe({ plannedBooks ->
+                val inProgressCount = plannedBooks.count { it.priority > 0 }
+                profileDoingCount.text = getString(
+                    R.string.profile_caption_doing,
+                    inProgressCount
                 )
                 )
-                profileReviewsCount.text = getString(
-                    R.string.profile_caption_reviews,
-                    finishedBooks.count { it.notes.isNotEmpty() }
+                profileTodoCount.text = getString(
+                    R.string.profile_caption_todo,
+                    plannedBooks.size - inProgressCount
                 )
                 )
             }, {
             }, {
-                logError("cannot check books count", it)
+                logError("cannot check planned books count", it)
             })
             })
     }
     }
 
 

+ 3 - 3
app/src/main/res/layout/profile_activity.xml

@@ -63,15 +63,15 @@
         android:layout_height="wrap_content">
         android:layout_height="wrap_content">
 
 
         <TextView
         <TextView
-            android:id="@+id/profileBooksCount"
+            android:id="@+id/profileTodoCount"
             style="@style/ProfileCaptionItem" />
             style="@style/ProfileCaptionItem" />
 
 
         <TextView
         <TextView
-            android:id="@+id/profileWishesCount"
+            android:id="@+id/profileDoingCount"
             style="@style/ProfileCaptionItem" />
             style="@style/ProfileCaptionItem" />
 
 
         <TextView
         <TextView
-            android:id="@+id/profileReviewsCount"
+            android:id="@+id/profileDoneCount"
             style="@style/ProfileCaptionItem" />
             style="@style/ProfileCaptionItem" />
 
 
     </LinearLayout>
     </LinearLayout>

+ 11 - 0
app/src/main/res/values-ru/strings.xml

@@ -16,6 +16,17 @@
     <string name="option_share_title">Отправить ссылку на профиль</string>
     <string name="option_share_title">Отправить ссылку на профиль</string>
     <string name="option_about">О приложении</string>
     <string name="option_about">О приложении</string>
 
 
+    <!-- profile -->
+    <string name="profile_caption_todo">%d\n0%%</string>
+    <string name="profile_caption_doing">%d\n1—99%%</string>
+    <string name="profile_caption_done">%d\n100%%</string>
+    <string name="profile_hint_nickname">псевдоним</string>
+    <string name="profile_hint_homepage">личная страница</string>
+
+    <!-- profile menu -->
+    <string name="profile_option_edit">Редактировать</string>
+    <string name="profile_option_share">Поделиться</string>
+
     <!-- books -->
     <!-- books -->
     <string name="book_header_todo">К прочтению</string>
     <string name="book_header_todo">К прочтению</string>
     <string name="book_header_done_first">Прочитано в %s г.</string>
     <string name="book_header_done_first">Прочитано в %s г.</string>

+ 5 - 3
app/src/main/res/values/strings.xml

@@ -17,9 +17,11 @@
     <string name="option_about">About</string>
     <string name="option_about">About</string>
 
 
     <!-- profile -->
     <!-- profile -->
-    <string name="profile_caption_books">%d\nbooks</string>
-    <string name="profile_caption_wishes">%d\nwishes</string>
-    <string name="profile_caption_reviews">%d\nreviews</string>
+    <string name="profile_caption_todo">%d\ntodo</string>
+    <string name="profile_caption_doing">%d\ndoing</string>
+    <string name="profile_caption_done">%d\ndone</string>
+    <string name="profile_hint_nickname">nickname</string>
+    <string name="profile_hint_homepage">homepage</string>
 
 
     <!-- profile menu -->
     <!-- profile menu -->
     <string name="profile_option_edit">Edit</string>
     <string name="profile_option_edit">Edit</string>