void YouTubeThumbnailView.IOnInitializedListener.OnInitializationSuccess(YouTubeThumbnailView view, IYouTubeThumbnailLoader loader) { loader.SetOnThumbnailLoadedListener(this); thumbnailViewToLoaderMap.Add(view, loader); view.SetImageResource(Resource.Drawable.loading_thumbnail); var videoId = (string)view.Tag; loader.SetVideo(videoId); }
public void OnInitializationSuccess(YouTubeThumbnailView view, IYouTubeThumbnailLoader loader) { loader.SetOnThumbnailLoadedListener(this); OnInitializationSuccessAction?.Invoke(view, loader); //thumbnailViewToLoaderMap.put(view, loader); view.SetImageResource(Resource.Drawable.loading_thumbnail); string videoId = (string)view.Tag; loader.SetVideo(videoId); }
public override View GetView(int position, View convertView, ViewGroup parent) { View view = convertView; VideoEntry entry = entries[position]; // There are three cases here if (view == null) { // 1) The view has not yet been created - we need to initialize the YouTubeThumbnailView. view = inflater.Inflate(Resource.Layout.video_list_item, parent, false); YouTubeThumbnailView thumbnail = (YouTubeThumbnailView)view.FindViewById(Resource.Id.thumbnail); thumbnail.Tag = (entry.videoId); thumbnail.Initialize(DeveloperKey.DEVELOPER_KEY, thumbnailListener); } else { YouTubeThumbnailView thumbnail = (YouTubeThumbnailView)view.FindViewById(Resource.Id.thumbnail); IYouTubeThumbnailLoader loader = thumbnailViewToLoaderMap[thumbnail]; if (loader == null) { // 2) The view is already created, and is currently being initialized. We store the // current videoId in the tag. thumbnail.Tag = (entry.videoId); } else { // 3) The view is already created and already initialized. Simply Set the right videoId // on the loader. thumbnail.SetImageResource(Resource.Drawable.loading_thumbnail); loader.SetVideo(entry.videoId); } } TextView label = ((TextView)view.FindViewById(Resource.Id.text)); label.Text = (entry.text); label.Visibility = (labelsVisible ? ViewStates.Visible : ViewStates.Gone); return(view); }