private void updateDataBasedOn(LinkPreviewLoader.Result result) { if (result.RequestWasSuccessful) { _data = result.Data; } }
private MetaData extractDescriptionFrom(LinkPreviewData data) { DescriptionData result = _metaDataFactory.CreateNew(MetaDataType.Description) as DescriptionData; result.Content = data.description; return(result); }
private MetaData extractPreviewImageFrom(LinkPreviewData data) { PreviewImageData result = _metaDataFactory.CreateNew(MetaDataType.PreviewImage) as PreviewImageData; result.Uri = _imageFilePathConverter.Convert(data.image).Uri; return(result); }
private MetaData extractTitleFrom(LinkPreviewData data) { TitleData result = _metaDataFactory.CreateNew(MetaDataType.Title) as TitleData; result.Content = data.title; return(result); }
private void reset() { _container.SetActive(false); _data = null; _previewImage.texture = null; stopCurrentImageLoading(); stopCurrentPreviewLoading(); }
private List <MetaData> extractMetaDataFrom(LinkPreviewData data) { List <MetaData> extractedMetaData = new List <MetaData>(); if (!string.IsNullOrEmpty(data.description)) { extractedMetaData.Add(extractDescriptionFrom(data)); } if (!string.IsNullOrEmpty(data.image) && imagePathIsValid(data.image)) { extractedMetaData.Add(extractPreviewImageFrom(data)); } if (!string.IsNullOrEmpty(data.title)) { extractedMetaData.Add(extractTitleFrom(data)); } return(extractedMetaData); }
private IEnumerator loadPreviewData(LoadRequest request) { UnityWebRequest www = UnityWebRequest.Get(string.Format(_requestURL, _apiKey, request.Uri)); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.LogError(www.error); _callbacks[request].Invoke(new Result(www.error)); } else { string json = www.downloadHandler.text; LinkPreviewData data = JsonUtility.FromJson <LinkPreviewData>(json); _callbacks[request].Invoke(new Result(data)); } www.Dispose(); }
public Result(LinkPreviewData data) { Error = string.Empty; Data = data; }