public void SetProgram(GameObject listItem) { program = listItem.GetComponent <ProgramContainer> ().GetProgram(); titleText.text = ProgramParser.GetTitle(program); SetThumbnail(); descriptionText.text = ProgramParser.GetDescription(program); SetOnDemand(); SetCategory(); ClearPublicationEvents(); SetPublicationEvents(); }
private IEnumerator GetJSON(string url) { UnityWebRequest request = UnityWebRequest.Get(url); Debug.Log(url); request.SetRequestHeader("Content-Type", "application/json"); yield return(request.Send()); if (request.isError) { Debug.Log("json request error"); Debug.Log(request.error); loadingWheel.SetActive(false); errorMessage.SetActive(true); } else { Debug.Log(request.downloadHandler.text); list = ProgramParser.ProgramListFromJSON(request.downloadHandler.text); if (list.data.Length > 0) { PopulateListView(); if (amountAddedToList == targetResultOffset || list.meta.count < targetResultOffset) { Debug.Log("Total amount added to list view: " + amountAddedToList); SetButtonEvents(); if (isNewSearch) { listViewResultCount.text = list.meta.count + " Results"; panelController.Open(); isNewSearch = false; loadingWheel.SetActive(false); } } } } //Prevent the ListView from updating twice by waiting a frame yield return(new WaitForEndOfFrame()); isLoading = false; }
public void SetPublicationEvent(PublicationEvent newPublicationEvent) { publicationEvent = newPublicationEvent; if (publicationEvent.type == "OnDemandPublication") { type.text = "On Demand"; date.text = "From: "; duration.text = "Duration: " + ProgramParser.GetReadableDuration(publicationEvent.media.duration); downloadable.text = "Downloadable"; } else if (publicationEvent.type == "ScheduledTransmission") { type.text = "Live"; date.text = "On: "; duration.text = "Duration: " + ProgramParser.GetReadableDuration(publicationEvent.duration); downloadable.text = ""; } region.text = publicationEvent.region; date.text += ProgramParser.GetReadableDate(publicationEvent.startTime); }
private void PopulateListView() { foreach (Program loopProgram in list.data) { surplusOffset++; if (loopProgram.type.ToLower() == category || category == "program") { if (amountAddedToList < targetResultOffset) { //add item to scrollView GameObject loopListItem = Instantiate(listItem, listViewContent.transform); //add data container to item and set data on container loopListItem.AddComponent <ProgramContainer> ().SetProgram(loopProgram); //set item title //Some Finnish titles aren't available: in that case, the english or swedish is used loopListItem.transform.GetComponentInChildren <Text> ().text = ProgramParser.GetTitle(loopProgram); //store item listItems.Add(loopListItem); amountAddedToList++; } else { //once desired amount of results are added, stop this function Debug.Log(amountAddedToList + " added to listview"); currentOffset += surplusOffset; return; } } } Debug.Log(amountAddedToList + " added to listview"); currentOffset += surplusOffset; //if all results have been added, stop trying to add more if (list.meta.count < targetResultOffset) { return; } //add another round of results to reach desired amount if (amountAddedToList < targetResultOffset) { AddResults(); } }