示例#1
0
    //--------------------------------------
    //  EVENTS
    //--------------------------------------

    private void OnUserLikesResult(FBResult result, FBLikesRetrieveTask task)
    {
        FB_APIResult r;

        if (result.Error != null)
        {
            r = new FB_APIResult(false, result.Error);
            r.Unity_FB_Result = result;
            OnLikesListLoadedAction(r);
            return;
        }


        Dictionary <string, object> JSON = ANMiniJSON.Json.Deserialize(result.Text) as Dictionary <string, object>;
        List <object> data = JSON["data"]  as List <object>;


        Dictionary <string, FBLikeInfo> userLikes = null;

        if (_likes.ContainsKey(task.userId))
        {
            userLikes = _likes[task.userId];
        }
        else
        {
            userLikes = new Dictionary <string, FBLikeInfo>();
            _likes.Add(task.userId, userLikes);
        }

        foreach (object row in data)
        {
            Dictionary <string, object> dataRow = row as Dictionary <string, object>;

            FBLikeInfo tpl = new FBLikeInfo();
            tpl.id       = System.Convert.ToString(dataRow["id"]);
            tpl.name     = System.Convert.ToString(dataRow["name"]);
            tpl.category = System.Convert.ToString(dataRow["category"]);

            if (userLikes.ContainsKey(tpl.id))
            {
                userLikes[tpl.id] = tpl;
            }
            else
            {
                userLikes.Add(tpl.id, tpl);
            }
        }

        r = new FB_APIResult(true, result.Text);
        r.Unity_FB_Result = result;
        OnLikesListLoadedAction(r);
    }
示例#2
0
    //--------------------------------------
    //  EVENTS
    //--------------------------------------

    private void OnUserLikesResult(CEvent e)
    {
        FBLikesRetrieveTask task = e.dispatcher as FBLikesRetrieveTask;

        task.removeEventListener(BaseEvent.COMPLETE, OnUserLikesResult);

        FBResult result = e.data as FBResult;


        FB_APIResult r;

        if (result.Error != null)
        {
            r = new FB_APIResult(false, result.Error);
            r.Unity_FB_Result = result;
            dispatch(FacebookEvents.LIKES_LIST_LOADED, r);
            OnLikesListLoadedAction(r);
            return;
        }


        Dictionary <string, object> JSON = ANMiniJSON.Json.Deserialize(result.Text) as Dictionary <string, object>;
        List <object> data = JSON["data"]  as List <object>;


        Dictionary <string, FBLikeInfo> userLikes = null;

        if (_likes.ContainsKey(task.userId))
        {
            userLikes = _likes[task.userId];
        }
        else
        {
            userLikes = new Dictionary <string, FBLikeInfo>();
            _likes.Add(task.userId, userLikes);
        }

        foreach (object row in data)
        {
            Dictionary <string, object> dataRow = row as Dictionary <string, object>;

            FBLikeInfo tpl = new FBLikeInfo();
            tpl.id       = System.Convert.ToString(dataRow["id"]);
            tpl.name     = System.Convert.ToString(dataRow["name"]);
            tpl.category = System.Convert.ToString(dataRow["category"]);

            if (userLikes.ContainsKey(tpl.id))
            {
                userLikes[tpl.id] = tpl;
            }
            else
            {
                userLikes.Add(tpl.id, tpl);
            }
        }

        r = new FB_APIResult(true, result.Text);
        r.Unity_FB_Result = result;
        dispatch(FacebookEvents.LIKES_LIST_LOADED, r);
        OnLikesListLoadedAction(r);
    }