[Android] Fix CalledFromWrongThreadException

Nicolas Pomepuy git at videolan.org
Thu Sep 12 16:34:24 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Wed Sep 11 08:18:21 2019 +0200| [25f8fb78d0028f4719acf5fa971eb6c90202ffe2] | committer: Geoffrey Métais

Fix CalledFromWrongThreadException

> https://code.videolan.org/videolan/vlc-android/commit/25f8fb78d0028f4719acf5fa971eb6c90202ffe2
---

 .../src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt    | 6 ++++--
 1 file changed, 4 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 e18195b58..055208a74 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
@@ -196,8 +196,10 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
                         else -> browserFavRepository.addNetworkFavItem(mw.uri, mw.title, mw.artworkURL)
                     }
                     favExists = !favExists
-                    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)
+                    withContext(Dispatchers.Main) {
+                        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