public void removeItem(int position) {
    final ItemType itemType = getItemTypeForPosition(position);
    switch (itemType) {
      case CLIENT:
        final boolean hadHiddenClients = !hiddenClients.isEmpty();
        final RemoteClient client =
            remoteClients.remove(
                transformAdapterPositionForDataStructure(ItemType.CLIENT, position));
        notifyItemRemoved(position);

        sState.setClientHidden(client.guid, true);
        hiddenClients.add(client);
        if (!hadHiddenClients) {
          // Add item for unhiding clients;
          remoteClients.add(null);
        } else {
          // Update "hidden clients" item because number of hidden clients changed.
          notifyItemChanged(getRemoteClientsHiddenItemsIndex());
        }
        break;
      case HISTORY:
        notifyItemRemoved(position);
        break;
    }
  }
  public void setClients(List<RemoteClient> clients) {
    hiddenClients.clear();
    remoteClients.clear();

    final Iterator<RemoteClient> it = clients.iterator();
    while (it.hasNext()) {
      final RemoteClient client = it.next();
      if (sState.isClientHidden(client.guid)) {
        hiddenClients.add(client);
        it.remove();
      }
    }

    remoteClients = clients;

    // Add item for unhiding clients.
    if (!hiddenClients.isEmpty()) {
      remoteClients.add(null);
    }

    notifyItemRangeChanged(0, remoteClients.size());
  }
  public void unhideClients(List<RemoteClient> selectedClients) {
    if (selectedClients.size() == 0) {
      return;
    }

    for (RemoteClient client : selectedClients) {
      sState.setClientHidden(client.guid, false);
      hiddenClients.remove(client);
    }

    final int insertIndex = getRemoteClientsHiddenItemsIndex();

    remoteClients.addAll(insertIndex, selectedClients);
    notifyItemRangeInserted(insertIndex, selectedClients.size());

    if (hiddenClients.isEmpty()) {
      // No more hidden clients, remove "unhide" item.
      remoteClients.remove(getRemoteClientsHiddenItemsIndex());
    } else {
      // Update "hidden clients" item because number of hidden clients changed.
      notifyItemChanged(getRemoteClientsHiddenItemsIndex());
    }
  }