コード例 #1
0
    /// <summary>
    /// 格式:
    /// Theme:LOL,Time:2018/02/01|Theme:LOL,Time:2018/02/01
    /// </summary>
    /// <param name="content"></param>
    private void ReceiveData(bool isSuccess, string dataStr)
    {
        if (!isSuccess)
        {
            _uiDataCB(false, null);
            return;
        }

        string[] dataBlock = dataStr.Split('\n');
        for (int i = 0; i < dataBlock.Length - 1; i++)
        {
            Dictionary <string, string> map = new Dictionary <string, string>();
            var      block = dataBlock[i];
            string[] lines = block.Split(',');
            for (int j = 0; j < lines.Length; j++)
            {
                string[] pair  = lines[j].Split(':');
                string   key   = pair[0];
                string   value = pair[1];

                map.Add(key, value);
            }
            maps.Add(map);
        }

        foreach (var map in maps)
        {
            string idStr      = map[ID];
            string iconPath   = map[ICON];
            string imagePath  = map[TEXTURE];
            string theme      = map[THEME];
            string time       = map[TIME];
            string content    = map[CONTENT];
            string collectStr = map[COLLECT];
            string likeStr    = map[LIKE];

            int    id      = int.Parse(idStr);
            Sprite icon    = AssetManager.LoadAssetFromAssetBundle <Sprite>("icon/" + iconPath);
            int    collect = int.Parse(collectStr);
            int    like    = int.Parse(likeStr);

            PlazaData data = new PlazaData(id, icon, theme, time, content, null, like, collect);
            datas.Add(data);

            DataFactory.GetInstance().RequestImageData(id, imagePath, SetDataImage);
        }
    }
コード例 #2
0
ファイル: PlazaFocusCell.cs プロジェクト: Eazey/NEA_Platform
    public override void InitCell(PlazaData data)
    {
        _icon.sprite = data.Icon;
        _theme.text  = data.Theme;
        _time.text   = data.Time;

        likeNum         = data.Like;
        _like_Text.text = likeNum.ToString();

        collectNum         = data.Collect;
        _collect_Text.text = collectNum.ToString();

        _image.sprite = data.Textures;
        _content.text = data.Content;

        float contentH = _content.preferredHeight;

        _content.rectTransform.sizeDelta = new Vector2(_content.rectTransform.sizeDelta.x, contentH);
    }
コード例 #3
0
ファイル: PlazaCell.cs プロジェクト: Eazey/NEA_Platform
    // 这里根据数据类型(纯文字,图文,文章等)的不同应该重载
    // 该对象应该作为参数发给数据类 由数据类决策方法
    public override void InitCell(PlazaData data)
    {
        _icon.sprite = data.Icon;
        _theme.text  = data.Theme;
        _time.text   = data.Time;

        likeNum         = data.Like;
        _like_Text.text = likeNum.ToString();

        collectNum         = data.Collect;
        _collect_Text.text = collectNum.ToString();

        GameObject contentGo = AssetManager.LoadGameObject(AssetManager.PlazaContentPath);

        AssetManager.SetParent(contentGo, _contentAncor);
        Text contentText = contentGo.GetComponent <Text>();

        contentText.text = data.Content;

        float contentH = contentText.preferredHeight;

        if (contentH > _normalHeight)
        {
            GameObject fixBtnGo = AssetManager.LoadGameObject(AssetManager.FixTextBtnPath);
            AssetManager.SetParent(fixBtnGo, _fixBtnAncor);
            float fixY  = fixBtnGo.GetComponent <RectTransform>().sizeDelta.y;
            float cellY = _cell.sizeDelta.y;
            _cell.sizeDelta = new Vector2(_cell.sizeDelta.x, fixY + cellY);

            FixTextBtn btn = fixBtnGo.GetComponent <FixTextBtn>();
            btn.RegisterEvent(() => Unfold(contentText), () => PackUp(contentText));
        }

        float cellH = contentH > _normalHeight ? _normalHeight : contentH;

        contentText.rectTransform.sizeDelta = new Vector2(contentText.rectTransform.sizeDelta.x, cellH);
        float cellY2 = _cell.sizeDelta.y;

        _cell.sizeDelta = new Vector2(_cell.sizeDelta.x, cellH + cellY2);
    }
コード例 #4
0
ファイル: ViewCell.cs プロジェクト: Eazey/NEA_Platform
 public abstract void InitCell(PlazaData data);