定义函数调用解析查询始终返回空,但解析成功返回

时间:2014-12-04 21:19:54

标签: android parse-platform

我已经定义了一个返回List of ParseUser的函数,该函数总是返回emtpy列表但是parse返回成功列表,这里是我的代码:

public static List<ParseUser> userFriends;

// The function takes the ParseUser and returns his/her friends from parse
public static List<ParseUser> getUserFriends(final ParseUser user) {
    userFriends = new ArrayList<ParseUser>();
    ParseQuery<ParseUser> queryFriends = ParseUser.getQuery();
    queryFriends.whereEqualTo("friendRelations", user);
    queryFriends.include("user");
    queryFriends.findInBackground(new FindCallback<ParseUser>() {
        @Override
        public void done(List<ParseUser> parseUsers, ParseException e) {
            if (e == null) {
                // This works perfect, userFriends has the returned list
                userFriends = parseUsers;
            } else {
                Log.e(TAG, e.getMessage());
            }
        }
    });
    // This always returns empty list, idk how userFriends doesn't have any value
    return userFriends;
}

我无法弄清楚这个函数如何返回空列表。

0 个答案:

没有答案