Fix chat list printing in Java example.

This commit is contained in:
levlam 2021-01-18 14:07:06 +03:00
parent 027c78c691
commit f37f9a78c1

View File

@ -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<OrderedChat> 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) {