/// <summary> /// Raises the update item event. /// </summary> /// <param name="itemCount">Item count.</param> /// <param name="obj">Object.</param> //protected string id; //protected string value; public void OnUpdateItem(int itemCount, GameObject obj) { //if (itemCount < 0 || itemCount >= max) if (itemCount < 0 || itemCount >= BoardListApi._httpCatchData.result.boards.Count) { obj.SetActive(false); } else { obj.SetActive(true); if (obj.GetComponentInChildren <BoardListItem> () != null) { var item = obj.GetComponentInChildren <BoardListItem> (); BoardListEntity.Board boardItem = null; boardItem = BoardListApi._httpCatchData.result.boards.ElementAt(itemCount); item.UpdateItem(itemCount, boardItem); } } }
/// <summary> /// Updates the item. /// </summary> /// <returns>The item.</returns> /// <param name="count">Count.</param> /// <param name="board">Board.</param> public void UpdateItem(int count, BoardListEntity.Board board = null) { if (board == null) { return; } this.transform.GetComponent <Button> ().onClick.AddListener(NomalClick); _categoryBg.SetActive(true); _bodyBg.SetActive(true); _prLongBg.SetActive(false); //広告表示の場合の処理。 if (board.is_banner == "1") { if (CommonConstants.IS_AD_NEND == true) { _categoryBg.SetActive(false); _bodyBg.SetActive(false); _prLongBg.SetActive(true); AppStartLoadBalanceManager.m_NendAdClient.LoadNativeAd((INativeAd ad, int code, string message) => { if (null != ad) { _prNendUrl = ad.PromotionUrl; this.transform.GetComponent <Button> ().onClick.RemoveAllListeners(); this.transform.GetComponent <Button> ().onClick.AddListener(NendAdClick); // 広告明示のテキストを取得します _prShortText.text = ad.GetAdvertisingExplicitlyText(AdvertisingExplicitly.AD); _prShortText.color = new Color(128 / 255.0f, 128 / 255.0f, 128 / 255.0f, 255); // 広告見出しを取得します _name.text = "<size=35>" + ad.ShortText + "</size>"; _prLongText.text = ad.LongText; // 広告画像のTextureをダウンロードします new HTTPRequest(new Uri(ad.AdImageUrl), (request, response) => { if (_profImage != null && response != null) { _profImage.texture = response.DataAsTexture2D; } }).Send(); // インプレッションの計測とクリック処理の登録を行います ad.Activate(this.gameObject, _profImage.gameObject); } else { Debug.Log("Failed to load ad. code =" + code + ", message = " + message); } }); } else { _addView.SetActive(true); _addView.name = board.url; new HTTPRequest(new Uri(board.image_url), (request, response) => _addRawImage.texture = response.DataAsTexture2D).Send(); } return; } _id = board.id; gameObject.name = board.id; _name.text = board.title; _category.text = board.board_category_name; string bodyStr = board.body.Replace("\n", ""); if (bodyStr.Length > 12) { body.text = bodyStr.Substring(0, 12) + "..."; } else { body.text = bodyStr; } _dateTime.text = board.time_ago; if (string.IsNullOrEmpty(board.user.profile_image_url) == false) { if (BulletinBoardEventManager.Instance._profTexCaches.ContainsKey(board.user.profile_image_url) == true) { _profImage.gameObject.SetActive(true); _profImage.texture = BulletinBoardEventManager.Instance._profTexCaches[board.user.profile_image_url]; return; } else { StartCoroutine(WwwToRendering(board.user.profile_image_url, _profImage)); } } }