mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
Fix duplicating downloads
This commit is contained in:
parent
1710340bbf
commit
e241207c1c
@ -23,10 +23,10 @@ import com.github.libretube.helpers.DownloadHelper
|
||||
import com.github.libretube.helpers.PreferenceHelper
|
||||
import com.github.libretube.util.TextUtils
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import java.io.IOException
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.IOException
|
||||
import retrofit2.HttpException
|
||||
|
||||
class DownloadDialog(
|
||||
|
@ -74,9 +74,10 @@ class DownloadsFragment : Fragment() {
|
||||
|
||||
val dbDownloads = runBlocking(Dispatchers.IO) {
|
||||
Database.downloadDao().getAll()
|
||||
}
|
||||
}.takeIf { it.isNotEmpty() } ?: return
|
||||
|
||||
downloads.clear()
|
||||
downloads.addAll(dbDownloads)
|
||||
if (downloads.isEmpty()) return
|
||||
|
||||
binding.downloadsEmpty.visibility = View.GONE
|
||||
binding.downloads.visibility = View.VISIBLE
|
||||
|
@ -215,21 +215,21 @@ class PlaylistFragment : Fragment() {
|
||||
}
|
||||
})
|
||||
|
||||
binding.playlistRecView.adapter = playlistAdapter
|
||||
binding.playlistScrollview.viewTreeObserver.addOnScrollChangedListener {
|
||||
if (_binding?.playlistScrollview?.canScrollVertically(1) == false &&
|
||||
!isLoading
|
||||
) {
|
||||
// append more playlists to the recycler view
|
||||
if (playlistType != PlaylistType.PUBLIC) {
|
||||
isLoading = true
|
||||
playlistAdapter?.showMoreItems()
|
||||
isLoading = false
|
||||
} else {
|
||||
fetchNextPage()
|
||||
binding.playlistRecView.adapter = playlistAdapter
|
||||
binding.playlistScrollview.viewTreeObserver.addOnScrollChangedListener {
|
||||
if (_binding?.playlistScrollview?.canScrollVertically(1) == false &&
|
||||
!isLoading
|
||||
) {
|
||||
// append more playlists to the recycler view
|
||||
if (playlistType != PlaylistType.PUBLIC) {
|
||||
isLoading = true
|
||||
playlistAdapter?.showMoreItems()
|
||||
isLoading = false
|
||||
} else {
|
||||
fetchNextPage()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// listener for swiping to the left or right
|
||||
if (playlistType != PlaylistType.PUBLIC) {
|
||||
|
Loading…
Reference in New Issue
Block a user