code: public Observable<List<Label>> getLabels() {
      return Observable.just(mails).flatMap(new Func1<List<Mail>, Observable<List<Label>>>() {
        @Override public Observable<List<Label>> call(List<Mail> mails) {
  
          delay();
  
          Observable error = checkExceptions();
          if (error != null) {
            return error;
          }
  
          List<Label> labels = new ArrayList<>(4);
          labels.add(INBOX_LABEL);
          labels.add(sentLabel);
          labels.add(spamLabel);
          labels.add(trashLabel);
  
          int inbox = 0;
          int spam = 0;
          int sent = 0;
          int trash = 0;
  
          for (Mail m : mails) {
  
            if (m.isRead()) {
              continue;
            }
  
            switch (m.getLabel()) {
              case Label.INBOX:
                inbox++;
                break;
  
              case Label.SENT:
                sent++;
                break;
  
              case Label.SPAM:
                spam++;
                break;
  
              case Label.TRASH:
                trash++;
                break;
            }
          }
  
          INBOX_LABEL.setUnreadCount(inbox);
          sentLabel.setUnreadCount(sent);
          spamLabel.setUnreadCount(spam);
          trashLabel.setUnreadCount(trash);
  
          return Observable.just(labels);
        }
      });
    }
docs: Get the labels with the number of unread mails.