public void updateValues() {
    if (conversationsAdapter == null) { // never initialized
      return;
    }

    conversations.clear(); // always clean, rebuild if authenticated
    conversationsAdapter.notifyDataSetChanged();

    if (layerClient.isAuthenticated()) {

      List<Conversation> convs = layerClient.getConversations();
      if (debug) Log.d(TAG, "updateValues() conv: " + convs.size());
      for (Conversation conv : convs) {
        // no participants means we are removed from conversation (disconnected conversation)
        if (conv.getParticipants().size() == 0) continue;

        // only ourselves in participant list is possible to happen, but there is nothing to do with
        // it
        // behave like conversation is disconnected
        if (conv.getParticipants().size() == 1 && conv.getParticipants().contains(globalUserId))
          continue;

        conversations.add(conv);
      }

      // the bigger .time the highest in the list
      Collections.sort(
          conversations,
          new Comparator<Conversation>() {
            public int compare(Conversation lhs, Conversation rhs) {
              long leftSentAt = 0;
              Message leftLastMessage = lhs.getLastMessage();
              if (leftLastMessage != null && leftLastMessage.getSentAt() != null) {
                leftSentAt = leftLastMessage.getSentAt().getTime();
              }
              long rightSentAt = 0;
              Message rightLastMessage = rhs.getLastMessage();
              if (rightLastMessage != null && rightLastMessage.getSentAt() != null) {
                rightSentAt = rightLastMessage.getSentAt().getTime();
              }
              long result = rightSentAt - leftSentAt;
              if (result == 0L) return 0;
              return result < 0L ? -1 : 1;
            }
          });
      if (conversations.size() > 0
          && findViewById(R.id.no_conversation_description).getVisibility() == View.VISIBLE) {
        findViewById(R.id.no_conversation_description).setVisibility(View.GONE);
        findViewById(R.id.atlas_conversations_view).setVisibility(View.VISIBLE);
      } else if (conversations.size() == 0) {
        TextView noConversationDescription =
            (TextView) findViewById(R.id.no_conversation_description);
        noConversationDescription.setVisibility(VISIBLE);
        if (accountType == 1) {
          noConversationDescription.setText(R.string.no_conversation_description_counselor);
        } else if (accountType == 0) {
          noConversationDescription.setText(R.string.no_conversation_description);
        } else if (accountType == 2) {
          noConversationDescription.setText(R.string.no_reports_description);
        }
      }
    }
  }
  public void init(
      final LayerClient layerClient,
      final ParticipantProvider participantProvider,
      int accountTypeLocal,
      Context contextLocal,
      String userId) {
    if (layerClient == null) throw new IllegalArgumentException("LayerClient cannot be null");
    if (participantProvider == null)
      throw new IllegalArgumentException("ParticipantProvider cannot be null");
    if (conversationsList != null)
      throw new IllegalStateException("AtlasConversationList is already initialized!");
    accountType = accountTypeLocal;
    globalUserId = layerClient.getAuthenticatedUserId();
    this.layerClient = layerClient;
    accountType = accountTypeLocal;
    context = contextLocal;
    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);

    // Use 1/8th of the available memory for this memory cache.
    final int cacheSize = maxMemory;
    mMemoryCache =
        new LruCache<String, Bitmap>(cacheSize) {
          @Override
          protected int sizeOf(String key, Bitmap bitmap) {
            // The cache size will be measured in kilobytes rather than
            // number of items.
            return bitmap.getByteCount() / 1024;
          }
        };
    new InitDiskCacheTask().execute();

    // inflate children:
    LayoutInflater.from(getContext())
        .inflate(com.layer.atlas.R.layout.atlas_conversations_list, this);

    this.conversationsList = (ListView) findViewById(com.layer.atlas.R.id.atlas_conversations_view);
    conversationsAdapter = new AtlasBaseSwipeAdapter(participantProvider);
    this.conversationsList.setAdapter(conversationsAdapter);

    conversationsList.setOnItemClickListener(
        new OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Conversation conv = conversations.get(position);

            if (clickListener != null) clickListener.onItemClick(conv);
          }
        });
    conversationsList.setOnItemLongClickListener(
        new OnItemLongClickListener() {
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            Conversation conv = conversations.get(position);
            conversationsAdapter.openItem(position);
            if (longClickListener != null) longClickListener.onItemLongClick(conv);
            return true;
          }
        });

    // clean everything if deathenticated (client will explode on .getConversation())
    // and rebuilt everything back after successful authentication
    layerClient.registerAuthenticationListener(
        new LayerAuthenticationListener() {
          public void onDeauthenticated(LayerClient client) {
            if (debug) Log.w(TAG, "onDeauthenticated() ");
            updateValues();
          }

          public void onAuthenticated(LayerClient client, String userId) {
            updateValues();
          }

          public void onAuthenticationError(LayerClient client, LayerException exception) {}

          public void onAuthenticationChallenge(LayerClient client, String nonce) {}
        });

    applyStyle();

    updateValues();

    mSwipeRefreshLayout =
        (SwipeRefreshLayout)
            findViewById(com.layer.atlas.R.id.conversation_list_swipe_refresh_layout);
    mSwipeRefreshLayout.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {

            refreshContent();
            updateValues();
          }
        });
  }