Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.StashAppAndroidTV"
android:usesCleartextTraffic="true">
android:usesCleartextTraffic="true"
android:largeHeap="true">
<activity
android:name=".RootActivity"
android:banner="@mipmap/ic_banner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.asFlow
import androidx.lifecycle.asLiveData
import androidx.lifecycle.viewModelScope
import coil3.imageLoader
import coil3.request.ImageRequest
import coil3.size.Size
import com.apollographql.apollo.api.Query
import com.github.damontecres.stashapp.StashApplication
import com.github.damontecres.stashapp.api.fragment.GalleryData
Expand Down Expand Up @@ -40,6 +43,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import timber.log.Timber
import kotlin.properties.Delegates

class ImageDetailsViewModel : ViewModel() {
Expand Down Expand Up @@ -240,6 +244,22 @@ class ImageDetailsViewModel : ViewModel() {
} else {
loadingState.value = ImageLoadingState.Error
}
if (position + 1 in pager.indices) {
try {
pager.getBlocking(position + 1)?.let { nextImage ->
Timber.v("Prefetching %s", nextImage.id)
val request =
ImageRequest
.Builder(StashApplication.getApplication())
.data(nextImage.paths.image)
.size(Size.ORIGINAL)
.build()
StashApplication.getApplication().imageLoader.enqueue(request)
}
} catch (ex: Exception) {
Timber.e(ex, "Error prefetching image")
}
}
} catch (ex: Exception) {
loadingState.value = ImageLoadingState.Error
LoggingCoroutineExceptionHandler(
Expand Down
Loading