mirror of
https://github.com/jellyfin/jellyfin-androidtv.git
synced 2025-03-01 03:05:46 +00:00
Fix race condition in PictureViewerViewModel
Using the showNext/showPrevious functions while the album is still loading can cause an IndexOutOfBoundsException. Check if the album is empty (default value) first before trying to read from it to avoid these crashes. (cherry picked from commit 9aa1759ae741509483dc6cb90a7091c9a12f036b)
This commit is contained in:
parent
0c667ab615
commit
0c9ba1ccec
@ -53,6 +53,8 @@ class PictureViewerViewModel(private val api: ApiClient) : ViewModel() {
|
||||
// Album actions
|
||||
|
||||
fun showNext() {
|
||||
if (album.isEmpty()) return
|
||||
|
||||
albumIndex++
|
||||
if (albumIndex == album.size) albumIndex = 0
|
||||
|
||||
@ -61,6 +63,8 @@ class PictureViewerViewModel(private val api: ApiClient) : ViewModel() {
|
||||
}
|
||||
|
||||
fun showPrevious() {
|
||||
if (album.isEmpty()) return
|
||||
|
||||
albumIndex--
|
||||
if (albumIndex == -1) albumIndex = album.size - 1
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user