Google has released the YouTube api for Google. In that api is a YouTubeThumbnailView to display thumbnails of a movie.
I want to display the thumbnails in a ListView. I have made a adapter to make the views. But I’m not sure how to handle this.
In the getView of my ListView-adapter I inflate a layout which include the YouTubeThumbnailView. According to the documentation (https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubeThumbnailView) I should call the initialize method.
I’m wondering if I need to call the initialize method one time or also call this if the view is re-used by the ListView? There is no way to check if the YouTubeThumbnailView is already initialized? So I guess I should call it multiple times. But I have no idea if that is allowed?
You should only call it once, but save a reference to the loader once it’s initialized. One way to deal with this is to keep a map from
ViewtoYouTubeThumbnailLoader. IngetView, there are 3 cases:In case 1 and 3, you need to remember what the loader should do when it’s initialized. You can e.g. save the video id in the tag of the view.
Example code:
And in your thumbnailListener: