Ejemplo n.º 1
0
    public IEnumerator ApplyFilter(System.Func <Place, bool> filter)
    {
        // Waiting data load complete
        yield return(PlacementDataSource.WaitingDataReady());

        // Load data to list
        this.currentData = PlacementDataSource.GetPlacesCollectionWithFilter(filter);
        Scroll.ApplyDataTo(currentData.Places.Length, 0, InfiniteScroll.Direction.Bottom);
    }
Ejemplo n.º 2
0
    void Start()
    {
        scroll.FillItem += (int index, GameObject item) => {
            //这里我们可以填写和修改item prefab
            //改变文字,图像等
            //通过索引,我们可以从JSON数组获取数据,例如
            item.transform.GetChild(0).GetComponent <Text> ().text = "item #" + index;
        };

        scroll.PullLoad += (InfiniteScroll.Direction obj) => {
            //这里我们监听拖拽刷新事件并处理它
            //它可以将数据从服务器加载到JSON对象并附加到列表
            //做到这一点,调用ApplyDataTo函数,其中arg1 =通用项追加后计数,arg2 = count追加,arg3 =追加方向(顶部或底部)
            count += 20;
            scroll.ApplyDataTo(count, 20, obj);
        };

        //函数初始化无限滚动
        scroll.InitData(count);
    }
Ejemplo n.º 3
0
    void Start()
    {
        scroll.FillItem += (int index, GameObject item) => {
            // here we can fill and modify item prefab
            // change text, image, ect
            // by index we can get data from JSON array, i.g.
            item.transform.GetChild(0).GetComponent <Text> ().text = "item #" + index;
        };

        scroll.PullLoad += (InfiniteScroll.Direction obj) => {
            // here we listen pull-to-refresh event and process it
            // it could be loading data from server to JSON object and append to list
            // to do it, call ApplyDataTo function, where arg1 = common items count after appending, arg2 = count to append, arg3 = direction to append (top or bottom)
            count += 20;
            scroll.ApplyDataTo(count, 20, obj);
        };

        // function to initialize infinite scroll
        scroll.InitData(count);
    }
Ejemplo n.º 4
0
    void OnPullItem(InfiniteScroll.Direction direction)
    {
        int index = _list.Count;

        if (direction == InfiniteScroll.Direction.Top)
        {
            for (int i = 0; i < PullCount; i++)
            {
                _list.Insert(0, index);
                index++;
            }
        }
        else
        {
            for (int i = 0; i < PullCount; i++)
            {
                _list.Add(index);
                index++;
            }
        }
        Scroll.ApplyDataTo(_list.Count, PullCount, direction);
    }
Ejemplo n.º 5
0
 //这里我们监听拖拽刷新事件并处理它
 //它可以将数据从服务器加载到JSON对象并附加到列表
 //做到这一点,调用ApplyDataTo函数,其中arg1 =通用项追加后计数,arg2 = count追加,arg3 =追加方向(顶部或底部)
 void scroll_PullLoad(InfiniteScroll.Direction obj)
 {
     count += 20;
     scroll.ApplyDataTo(count, 20, obj);
 }