From f37f9a78c1385237b96af66ae5564256b3e7ec42 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 18 Jan 2021 14:07:06 +0300 Subject: [PATCH] Fix chat list printing in Java example. --- example/java/org/drinkless/tdlib/example/Example.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/example/java/org/drinkless/tdlib/example/Example.java b/example/java/org/drinkless/tdlib/example/Example.java index 779ef6318..804cf5df4 100644 --- a/example/java/org/drinkless/tdlib/example/Example.java +++ b/example/java/org/drinkless/tdlib/example/Example.java @@ -248,7 +248,7 @@ public final class Example { private static void getMainChatList(final int limit) { synchronized (mainChatList) { if (!haveFullMainChatList && limit > mainChatList.size()) { - // have enough chats in the chat list or chat list is too small + // send GetChats request if there are some unknown chats and have not enough known chats long offsetOrder = Long.MAX_VALUE; long offsetChatId = 0; if (!mainChatList.isEmpty()) { @@ -281,11 +281,10 @@ public final class Example { return; } - // have enough chats in the chat list to answer request java.util.Iterator iter = mainChatList.iterator(); System.out.println(); System.out.println("First " + limit + " chat(s) out of " + mainChatList.size() + " known chat(s):"); - for (int i = 0; i < limit; i++) { + for (int i = 0; i < limit && i < mainChatList.size(); i++) { long chatId = iter.next().chatId; TdApi.Chat chat = chats.get(chatId); synchronized (chat) {