package com.quickblox.qmunicate.ui.main;

import android.content.Context;
import android.os.Bundle;

import com.quickblox.internal.core.exception.QBResponseException;
import com.quickblox.internal.core.request.QBPagedRequestBuilder;
import com.quickblox.module.users.QBUsers;
import com.quickblox.module.users.model.QBUser;
import com.quickblox.qmunicate.core.ui.BaseLoader;
import com.quickblox.qmunicate.model.Friend;

import java.util.List;

public class UserListLoader extends BaseLoader<List<Friend>> {
    public static final int ID = 3;

    public UserListLoader(Context context) {
        super(context);
    }

    public static Arguments newArguments(String constraint, int page, int perPage) {
        Arguments arguments = new Arguments();
        arguments.constraint = constraint;
        arguments.page = page;
        arguments.perPage = perPage;
        return arguments;
    }

    @Override
    public List<Friend> performInBackground() throws QBResponseException {
        Arguments arguments = (Arguments) args;

        QBPagedRequestBuilder requestBuilder = new QBPagedRequestBuilder();
        requestBuilder.setPage(arguments.page);
        requestBuilder.setPerPage(arguments.perPage);

        Bundle params = new Bundle();
        List<QBUser> users = QBUsers.getUsersByFullName(arguments.constraint, requestBuilder, params);

        return Friend.createFriends(users);
    }

    private static class Arguments extends BaseLoader.Args {
        String constraint;
        int page;
        int perPage;
    }
}
@@ -313,24 +313,60 @@
 del.QBUser;%0A
+import com.quickblox.qmunicate.App;%0A
 import com.q
@@ -1393,22 +1393,38 @@
         
-return
+List%3CFriend%3E friends =
  Friend.
@@ -1445,16 +1445,106 @@
 users);%0A
+        friends.remove(new Friend(App.getInstance().getUser()));%0A%0A        return friends;%0A
     %7D%0A%0A 

fix occurrences of current user