[Android] Code cleanup
Nicolas Pomepuy
git at videolan.org
Mon Sep 23 18:10:26 CEST 2019
vlc-android | branch: 3.2.x | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Wed Sep 11 10:54:31 2019 +0200| [7cafb7bebd837d51003e58624fe73cd53d11c211] | committer: Geoffrey Métais
Code cleanup
(cherry picked from commit f948bdea107701940695801c9a9e32e160445f15)
> https://code.videolan.org/videolan/vlc-android/commit/7cafb7bebd837d51003e58624fe73cd53d11c211
---
.../src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
index 77a71deb9..cdb0fcbbe 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
@@ -182,7 +182,10 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
animationDelegate.setVisibility(binding.favoriteButton, View.VISIBLE)
animationDelegate.setVisibility(binding.imageButtonFavorite, View.VISIBLE)
animationDelegate.setVisibility(binding.favoriteDescription, View.VISIBLE)
- favExists = withContext(Dispatchers.IO) { if (item == null) false else if (item is MediaWrapper) browserFavRepository.browserFavExists((item as MediaWrapper).uri) else false }
+ favExists = withContext(Dispatchers.IO) {
+ (item as? MediaWrapper)?.let { browserFavRepository.browserFavExists(it.uri) }
+ ?: false
+ }
binding.favoriteButton.setImageResource(if (favExists) R.drawable.ic_menu_fav_tv else R.drawable.ic_menu_not_fav_tv)
binding.imageButtonFavorite.setImageResource(if (favExists) R.drawable.ic_menu_fav_tv_normal else R.drawable.ic_menu_not_fav_tv_normal)
}
@@ -196,7 +199,7 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
else -> browserFavRepository.addNetworkFavItem(mw.uri, mw.title, mw.artworkURL)
}
favExists = !favExists
- withContext(Dispatchers.Main) {
+ launch {
binding.favoriteButton.setImageResource(if (favExists) R.drawable.ic_menu_fav_tv else R.drawable.ic_menu_not_fav_tv)
binding.imageButtonFavorite.setImageResource(if (favExists) R.drawable.ic_menu_fav_tv_normal else R.drawable.ic_menu_not_fav_tv_normal)
}
More information about the Android
mailing list