refactor: remove bottom reached toast and show progress indicator instead

This commit is contained in:
Bnyro 2023-11-27 20:23:58 +01:00
parent da0f97a27b
commit acb8e8ec03
13 changed files with 5 additions and 25 deletions

View File

@ -55,7 +55,7 @@ class CommentsMainFragment : Fragment() {
commentsSheet?.binding?.btnScrollToTop?.isVisible = viewModel.currentCommentsPosition != 0
if (!viewBinding.commentsRV.canScrollVertically(1)) {
viewModel.fetchNextComments(requireContext())
viewModel.fetchNextComments()
}
}
commentsSheet?.updateFragmentInfo(false, getString(R.string.comments))

View File

@ -5,7 +5,6 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.core.view.updatePadding
@ -80,10 +79,7 @@ class CommentsRepliesFragment : Fragment() {
binding.commentsRV.viewTreeObserver.addOnScrollChangedListener {
if (_binding?.commentsRV?.canScrollVertically(1) == false && ::repliesPage.isInitialized) {
if (repliesPage.nextpage == null) {
Toast.makeText(context, R.string.bottom_reached, Toast.LENGTH_SHORT).show()
return@addOnScrollChangedListener
}
if (repliesPage.nextpage == null) return@addOnScrollChangedListener
fetchReplies(videoId, repliesPage.nextpage!!)
}

View File

@ -1,16 +1,12 @@
package com.github.libretube.ui.models
import android.content.Context
import android.util.Log
import android.widget.Toast
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.api.obj.CommentsPage
import com.github.libretube.extensions.TAG
import com.github.libretube.extensions.toastFromMainDispatcher
import com.github.libretube.ui.extensions.filterNonEmptyComments
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -58,11 +54,7 @@ class CommentsViewModel : ViewModel() {
}
}
fun fetchNextComments(context: Context) {
if (nextPage == null) {
Toast.makeText(context, R.string.bottom_reached, Toast.LENGTH_SHORT).show()
}
fun fetchNextComments() {
if (isLoading.value == true || nextPage == null || videoId == null) return
isLoading.value = true

View File

@ -7,7 +7,8 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/commentsRV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:clipToPadding="false"
android:paddingVertical="15dp" />

View File

@ -529,6 +529,5 @@
<string name="successfully_removed_from_playlist">\"%1$s\" oynatma siyahısından uğurla silindi.</string>
<string name="watched">Baxılan</string>
<string name="finished">Bitdi</string>
<string name="bottom_reached">Aşağıya çatdı!</string>
<string name="no_segments_found">Bu video üçün hələ heç bir bölüm yoxdur.</string>
</resources>

View File

@ -534,7 +534,6 @@
<string name="repeat_mode_all">Паўтарыце ўсё</string>
<string name="successfully_removed_from_playlist">\"%1$s\" быў выдалены з падборкі.</string>
<string name="watched">Прагледжана</string>
<string name="bottom_reached">Дно дасягнута!</string>
<string name="finished">Скончана</string>
<string name="no_segments_found">Для гэтага відэа яшчэ няма сегментаў.</string>
</resources>

View File

@ -532,6 +532,5 @@
<string name="successfully_removed_from_playlist">Video „%1$s“ úspěšně odebráno z playlistu.</string>
<string name="watched">Zhlédnuto</string>
<string name="finished">Dokončeno</string>
<string name="bottom_reached">Níž to nejde!</string>
<string name="no_segments_found">U tohoto videa zatím nejsou žádné segmenty.</string>
</resources>

View File

@ -533,5 +533,4 @@
<string name="watched">Vistos</string>
<string name="finished">Acabados</string>
<string name="no_segments_found">Aún no hay partes para este vídeo.</string>
<string name="bottom_reached">¡Se alcanzó el final!</string>
</resources>

View File

@ -525,7 +525,6 @@
<string name="repeat_mode_all">すべてリピート</string>
<string name="successfully_removed_from_playlist">再生リストから以下を削除しました: %1$s</string>
<string name="watched">視聴済み</string>
<string name="bottom_reached">最後まで達しました!</string>
<string name="finished">完了</string>
<string name="no_segments_found">シーンがまだ未登録の動画です。</string>
</resources>

View File

@ -535,6 +535,5 @@
<string name="successfully_removed_from_playlist">\"%1$s\" было успешно удалено из плейлиста.</string>
<string name="watched">Просмотрено</string>
<string name="finished">Завершено</string>
<string name="bottom_reached">Дно достигнуто!</string>
<string name="no_segments_found">Для этого видео пока нет сегментов.</string>
</resources>

View File

@ -534,7 +534,6 @@
<string name="repeat_mode_all">Повторити все</string>
<string name="successfully_removed_from_playlist">\"%1$s\" вилучено з добірки.</string>
<string name="watched">Переглянуто</string>
<string name="bottom_reached">Дно досягнуто!</string>
<string name="finished">Завершено</string>
<string name="no_segments_found">Для цього відео ще немає сегментів.</string>
</resources>

View File

@ -526,6 +526,5 @@
<string name="successfully_removed_from_playlist">成功从播放列表中移除了“%1$s”。</string>
<string name="watched">已关注</string>
<string name="finished">已完成</string>
<string name="bottom_reached">已到达底部!</string>
<string name="no_segments_found">此视频尚无分段。</string>
</resources>

View File

@ -495,7 +495,6 @@
<string name="successfully_removed_from_playlist">Successfully removed \"%1$s\" from the playlist.</string>
<string name="watched">Watched</string>
<string name="no_segments_found">There are no segments for this video yet.</string>
<string name="bottom_reached">Bottom reached!</string>
<string name="start_sleep_timer">Start sleep timer</string>
<string name="disable_sleep_timer">Disable sleep timer</string>
<string name="time_in_minutes">Time in minutes</string>