[Android] Fix TypeCastException
Nicolas Pomepuy
git at videolan.org
Wed Aug 12 14:04:20 CEST 2020
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Aug 11 14:29:02 2020 +0200| [6688f5ad07317f5873545590255079bca4579807] | committer: Nicolas Pomepuy
Fix TypeCastException
> https://code.videolan.org/videolan/vlc-android/commit/6688f5ad07317f5873545590255079bca4579807
---
.../television/ui/browser/FileBrowserTvFragment.kt | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/application/television/src/main/java/org/videolan/television/ui/browser/FileBrowserTvFragment.kt b/application/television/src/main/java/org/videolan/television/ui/browser/FileBrowserTvFragment.kt
index 61e69e281..57d3fd38f 100644
--- a/application/television/src/main/java/org/videolan/television/ui/browser/FileBrowserTvFragment.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/browser/FileBrowserTvFragment.kt
@@ -251,16 +251,18 @@ class FileBrowserTvFragment : BaseBrowserTvFragment<MediaLibraryItem>(), PathAda
}
private val favoriteClickListener: (View) -> Unit = {
- lifecycleScope.launch {
- val mw = (item as MediaWrapper)
- when {
- browserFavRepository.browserFavExists(mw.uri) -> browserFavRepository.deleteBrowserFav(mw.uri)
- mw.uri.scheme == "file" -> browserFavRepository.addLocalFavItem(mw.uri, mw.title, mw.artworkURL)
- else -> browserFavRepository.addNetworkFavItem(mw.uri, mw.title, mw.artworkURL)
+ item.let {item ->
+ lifecycleScope.launch {
+ val mw = (item as MediaWrapper)
+ when {
+ browserFavRepository.browserFavExists(mw.uri) -> browserFavRepository.deleteBrowserFav(mw.uri)
+ mw.uri.scheme == "file" -> browserFavRepository.addLocalFavItem(mw.uri, mw.title, mw.artworkURL)
+ else -> browserFavRepository.addNetworkFavItem(mw.uri, mw.title, mw.artworkURL)
+ }
+ favExists = !favExists
+ if (!isRootLevel) binding.favoriteButton.setImageResource(if (favExists) R.drawable.ic_bookmark else R.drawable.ic_bookmark_outline)
+ binding.imageButtonFavorite.setImageResource(if (favExists) R.drawable.ic_fabtvmini_bookmark else R.drawable.ic_fabtvmini_bookmark_outline)
}
- favExists = !favExists
- if (!isRootLevel) binding.favoriteButton.setImageResource(if (favExists) R.drawable.ic_bookmark else R.drawable.ic_bookmark_outline)
- binding.imageButtonFavorite.setImageResource(if (favExists) R.drawable.ic_fabtvmini_bookmark else R.drawable.ic_fabtvmini_bookmark_outline)
}
}
More information about the Android
mailing list