diff --git a/app/src/main/java/com/github/libretube/ui/extensions/SetupNotificationBell.kt b/app/src/main/java/com/github/libretube/ui/extensions/SetupNotificationBell.kt index 8f36e82ab..eac39b7ab 100644 --- a/app/src/main/java/com/github/libretube/ui/extensions/SetupNotificationBell.kt +++ b/app/src/main/java/com/github/libretube/ui/extensions/SetupNotificationBell.kt @@ -7,7 +7,6 @@ import com.google.android.material.button.MaterialButton fun MaterialButton.setupNotificationBell(channelId: String) { var isIgnorable = PreferenceHelper.isChannelNotificationIgnorable(channelId) - Log.e(channelId, isIgnorable.toString()) setIconResource(if (isIgnorable) R.drawable.ic_bell else R.drawable.ic_notification) setOnClickListener { diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt index 20eb662d8..eb5ce2847 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt @@ -35,8 +35,6 @@ import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper import com.github.libretube.util.PlayingQueue import com.github.libretube.util.TextUtils -import java.io.IOException -import retrofit2.HttpException class PlaylistFragment : BaseFragment() { private lateinit var binding: FragmentPlaylistBinding @@ -47,7 +45,7 @@ class PlaylistFragment : BaseFragment() { private var playlistType: PlaylistType = PlaylistType.PUBLIC // runtime variables - private val playlistFeed = mutableListOf() + private var playlistFeed = mutableListOf() private var playlistAdapter: PlaylistAdapter? = null private var nextPage: String? = null private var isLoading = true @@ -107,14 +105,11 @@ class PlaylistFragment : BaseFragment() { lifecycleScope.launchWhenCreated { val response = try { PlaylistsHelper.getPlaylist(playlistId!!) - } catch (e: IOException) { - Log.e(TAG(), "IOException, you might not have internet connection") - return@launchWhenCreated - } catch (e: HttpException) { - Log.e(TAG(), "HttpException, unexpected response") + } catch (e: Exception) { + Log.e(TAG(), e.toString()) return@launchWhenCreated } - playlistFeed.addAll(response.relatedStreams.orEmpty()) + playlistFeed = response.relatedStreams.orEmpty().toMutableList() binding.playlistScrollview.visibility = View.VISIBLE nextPage = response.nextpage playlistName = response.name @@ -190,29 +185,29 @@ class PlaylistFragment : BaseFragment() { // listen for playlist items to become deleted playlistAdapter!!.registerAdapterDataObserver(object : - RecyclerView.AdapterDataObserver() { - override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) { - if (positionStart == 0) { - ImageHelper.loadImage( - playlistFeed.firstOrNull()?.thumbnail ?: "", - binding.thumbnail - ) - } - - val info = binding.playlistInfo.text.split(TextUtils.SEPARATOR) - binding.playlistInfo.text = ( - if (info.size == 2) { - info[0] + TextUtils.SEPARATOR - } else { - "" + RecyclerView.AdapterDataObserver() { + override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) { + if (positionStart == 0) { + ImageHelper.loadImage( + playlistFeed.firstOrNull()?.thumbnail ?: "", + binding.thumbnail + ) } - ) + getString( - R.string.videoCount, - playlistAdapter!!.itemCount.toString() - ) - super.onItemRangeRemoved(positionStart, itemCount) - } - }) + + val info = binding.playlistInfo.text.split(TextUtils.SEPARATOR) + binding.playlistInfo.text = ( + if (info.size == 2) { + info[0] + TextUtils.SEPARATOR + } else { + "" + } + ) + getString( + R.string.videoCount, + playlistAdapter!!.itemCount.toString() + ) + super.onItemRangeRemoved(positionStart, itemCount) + } + }) binding.playlistRecView.adapter = playlistAdapter binding.playlistScrollview.viewTreeObserver @@ -265,10 +260,10 @@ class PlaylistFragment : BaseFragment() { DatabaseHolder.Database.playlistBookmarkDao().getAll() }.firstOrNull { it.playlistId == playlistId } playlistBookmark?.let { - if (playlistBookmark.thumbnailUrl != response.thumbnailUrl) { - playlistBookmark.thumbnailUrl = response.thumbnailUrl + if (it.thumbnailUrl != response.thumbnailUrl) { + it.thumbnailUrl = response.thumbnailUrl query { - DatabaseHolder.Database.playlistBookmarkDao().update(playlistBookmark) + DatabaseHolder.Database.playlistBookmarkDao().update(it) } } }