mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20:32 +05:30
feat: show toast if the bottom/end of comments/replies is reached
This commit is contained in:
parent
155682bccc
commit
14c6ae36b5
@ -55,7 +55,7 @@ class CommentsMainFragment : Fragment() {
|
||||
commentsSheet?.binding?.btnScrollToTop?.isVisible = viewModel.currentCommentsPosition != 0
|
||||
|
||||
if (!viewBinding.commentsRV.canScrollVertically(1)) {
|
||||
viewModel.fetchNextComments()
|
||||
viewModel.fetchNextComments(requireContext())
|
||||
}
|
||||
}
|
||||
commentsSheet?.updateFragmentInfo(false, getString(R.string.comments))
|
||||
|
@ -5,6 +5,7 @@ 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
|
||||
@ -78,10 +79,12 @@ class CommentsRepliesFragment : Fragment() {
|
||||
binding.commentsRV.adapter = repliesAdapter
|
||||
|
||||
binding.commentsRV.viewTreeObserver.addOnScrollChangedListener {
|
||||
if (_binding?.commentsRV?.canScrollVertically(1) == false &&
|
||||
::repliesPage.isInitialized &&
|
||||
repliesPage.nextpage != null
|
||||
) {
|
||||
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
|
||||
}
|
||||
|
||||
fetchReplies(videoId, repliesPage.nextpage!!)
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,16 @@
|
||||
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
|
||||
@ -54,7 +58,11 @@ class CommentsViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun fetchNextComments() {
|
||||
fun fetchNextComments(context: Context) {
|
||||
if (nextPage == null) {
|
||||
Toast.makeText(context, R.string.bottom_reached, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
if (isLoading.value == true || nextPage == null || videoId == null) return
|
||||
|
||||
isLoading.value = true
|
||||
|
@ -495,6 +495,7 @@
|
||||
<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>
|
||||
|
||||
<!-- Notification channel strings -->
|
||||
<string name="download_channel_name">Download Service</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user