Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download smaller images on the watch #1062

Merged
merged 1 commit into from
Jun 8, 2023
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package au.com.shiftyjelly.pocketcasts.repositories.images

import android.content.Context
import au.com.shiftyjelly.pocketcasts.preferences.Settings
import au.com.shiftyjelly.pocketcasts.utils.Util

object PodcastImage {

Expand Down Expand Up @@ -31,7 +33,9 @@ object PodcastImage {
return String.format(STATIC_ARTWORK_JPG_URL, Settings.SERVER_STATIC_URL, size, uuid)
}

fun getLargeArtworkUrl(uuid: String): String {
return getArtworkUrl(960, uuid)
fun getLargeArtworkUrl(uuid: String, context: Context): String {
// The watch's smaller screen does not need such large images
val size = if (Util.isWearOs(context)) 480 else 960
return getArtworkUrl(size, uuid)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ open class PodcastImageLoader(

fun loadCoil(podcastUuid: String?, size: Int? = null, placeholder: Boolean = true, onComplete: () -> Unit = {}): ImageRequest.Builder {
if (podcastUuid == null) return loadNoPodcastCoil()
val url = if (size != null) PodcastImage.getArtworkUrl(size = size, uuid = podcastUuid) else PodcastImage.getLargeArtworkUrl(uuid = podcastUuid)
val url = if (size != null) {
PodcastImage.getArtworkUrl(size = size, uuid = podcastUuid)
} else {
PodcastImage.getLargeArtworkUrl(uuid = podcastUuid, context = context)
}

val placeholderDrawable = if (placeholder) placeholderResId() else 0
var builder = ImageRequest.Builder(context)
Expand Down Expand Up @@ -184,7 +188,7 @@ open class PodcastImageLoader(

private fun cacheSubscribedArtworkRequest(podcast: Podcast): ImageRequest {
return ImageRequest.Builder(context)
.data(PodcastImage.getLargeArtworkUrl(podcast.uuid))
.data(PodcastImage.getLargeArtworkUrl(uuid = podcast.uuid, context = context))
.memoryCachePolicy(CachePolicy.DISABLED)
.build()
}
Expand Down