/*
 * Copyright 2014 OpenMarket Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.matrix.androidsdk.rest.model.group;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * This class represents the group users in the server response.
 */
public class GroupUsers implements Serializable {

    public Integer totalUserCountEstimate;

    public List<GroupUser> chunk;

    /**
     * @return the users list
     */
    public List<GroupUser> getUsers() {
        if (null == chunk) {
            chunk = new ArrayList<>();
        }

        return chunk;
    }

    /**
     * @return the estimated users count
     */
    public int getEstimatedUsersCount() {
        if (null == totalUserCountEstimate) {
            totalUserCountEstimate = getUsers().size();
        }

        return totalUserCountEstimate;
    }
}

@@ -697,16 +697,68 @@
 ayList;%0A
+import java.util.HashMap;%0Aimport java.util.HashSet;%0A
 import j
@@ -976,16 +976,109 @@
 chunk;%0A%0A
+    // the server sends some duplicated entries%0A    private List%3CGroupUser%3E mFilteredUsers;%0A%0A
     /**%0A
@@ -1195,16 +1195,33 @@
         
+ mFilteredUsers =
  chunk =
@@ -1253,30 +1253,482 @@
    %7D
-%0A%0A        return chunk
+ else if (null == mFilteredUsers) %7B%0A            mFilteredUsers = new ArrayList%3C%3E();%0A%0A            HashMap%3CString, GroupUser%3E map = new HashMap%3C%3E();%0A%0A            for (GroupUser user : chunk) %7B%0A                if (null != user.userId) %7B%0A                    map.put(user.userId, user);%0A                %7D else %7B%0A                    mFilteredUsers.add(user);%0A                %7D%0A            %7D%0A            mFilteredUsers.addAll(map.values());%0A        %7D%0A%0A        return mFilteredUsers
 ;%0A  

Fix a server issue : some group members are duplicated