final ListView opponentsList = (ListView) view.findViewById(R.id.opponentsList);
ArrayList<Integer> userIds = new ArrayList<>();
QBUsers.getUsersByIDs(userIds, new QBPagedRequestBuilder(userIds.size(), 1), new QBEntityCallbackImpl<ArrayList<QBUser>>() {
@Override
public void onSuccess(ArrayList<QBUser> results, Bundle params) {
super.onSuccess(results,params);
List<QBUser> users = new ArrayList<>(results.size());
for (QBUser result : results)
{
// There mus be a more efficient, or at least better looking, way of doing this...
QBUser user = new QBUser();
user.setId(result.getId());
user.setLogin(result.getFullName());
users.add(user);
}
int i = searchIndexLogginedUser(users);
if (i >= 0)
users.remove(i);
// Prepare users list for simple adapter.
//
opponentsAdapter = new OpponentsAdapter(getActivity(), users);
opponentsList.setAdapter(opponentsAdapter);
}
});
progresDialog.dismiss();
在Android中使用quickblox示例从QBUsers.getUsersByIDs()获取用户数据时,不会继续成功方法?
它
没有显示,因为您没有在查询中提供任何值:
ArrayList<Integer> userIds = new ArrayList<>();
您应该先向此列表添加一个或多个 id,然后查询才能搜索以查看用户是否存在并在 onSuccess 方法中返回 QBUser。正确方法的一个例子是:
ArrayList<Integer> userIds = new ArrayList<>();
userIds.add(123456);
QBUsers.getUsersByIDs(userIds, new QBPagedRequestBuilder(userIds.size(), 1), new QBEntityCallbackImpl<ArrayList<QBUser>>() {
@Override
public void onSuccess(ArrayList<QBUser> results, Bundle params) {
super.onSuccess(results,params);
List<QBUser> users = new ArrayList<>(results.size());
for (QBUser result : results)
{
// There mus be a more efficient, or at least better looking, way of doing this...
QBUser user = new QBUser();
user.setId(result.getId());
user.setLogin(result.getFullName());
users.add(user);
}
int i = searchIndexLogginedUser(users);
if (i >= 0)
users.remove(i);
// Prepare users list for simple adapter.
//
opponentsAdapter = new OpponentsAdapter(getActivity(), users);
opponentsList.setAdapter(opponentsAdapter);
}
});
progresDialog.dismiss();
如果有一个用户具有此 id,那么它将在 onSuccess() 方法中返回该用户。希望这有帮助。