Separate imageListToDbUrl from choosePreferredImage

imageListToDbUrl should be used if the URL is going to be saved to the database, to avoid saving nothing in case at the moment of saving the user preference is to not show images.
This commit is contained in:
Stypox 2023-05-02 21:36:11 +02:00
parent 37af2c87e8
commit 87dca0f7ec
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23
9 changed files with 96 additions and 40 deletions

View file

@ -61,7 +61,6 @@ import org.schabi.newpipe.util.OnClickGesture
import org.schabi.newpipe.util.ServiceHelper
import org.schabi.newpipe.util.ThemeHelper.getGridSpanCountChannels
import org.schabi.newpipe.util.external_communication.ShareUtils
import org.schabi.newpipe.util.image.ImageStrategy
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
@ -342,8 +341,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
val actions = DialogInterface.OnClickListener { _, i ->
when (i) {
0 -> ShareUtils.shareText(
requireContext(), selectedItem.name, selectedItem.url,
ImageStrategy.choosePreferredImage(selectedItem.thumbnails)
requireContext(), selectedItem.name, selectedItem.url, selectedItem.thumbnails
)
1 -> ShareUtils.openUrlInBrowser(requireContext(), selectedItem.url)
2 -> deleteChannel(selectedItem)

View file

@ -74,7 +74,7 @@ class SubscriptionManager(context: Context) {
Completable.fromRunnable {
it.setData(
info.name,
ImageStrategy.choosePreferredImage(info.avatars),
ImageStrategy.imageListToDbUrl(info.avatars),
info.description,
info.subscriberCount
)
@ -105,7 +105,7 @@ class SubscriptionManager(context: Context) {
} else if (info is ChannelInfo) {
subscriptionEntity.setData(
info.name,
ImageStrategy.choosePreferredImage(info.avatars),
ImageStrategy.imageListToDbUrl(info.avatars),
info.description,
info.subscriberCount
)