From 6bd34065c4025abce18f783da4f46814fa206604 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 10 Apr 2019 19:26:16 +0300 Subject: [PATCH] Remove unnecessary ConcurrentLinkedQueue --- .../osmand/telegram/ui/SearchDialogFragment.kt | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/SearchDialogFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/SearchDialogFragment.kt index 1a703bc96f..ad1125b6ee 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/SearchDialogFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/SearchDialogFragment.kt @@ -31,7 +31,6 @@ import net.osmand.telegram.utils.OsmandLocationUtils import net.osmand.telegram.utils.UiUtils import net.osmand.util.MapUtils import org.drinkless.td.libcore.telegram.TdApi -import java.util.concurrent.ConcurrentLinkedQueue class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearchListener, TelegramLocationListener, TelegramCompassListener { @@ -47,9 +46,9 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch private lateinit var searchBox: EditText private lateinit var buttonsBar: LinearLayout - private val searchedChatsIds = ConcurrentLinkedQueue() - private val searchedPublicChatsIds = ConcurrentLinkedQueue() - private val searchedContactsIds = ConcurrentLinkedQueue() + private var searchedChatsIds = mutableSetOf() + private var searchedPublicChatsIds = mutableSetOf() + private var searchedContactsIds = mutableSetOf() private val selectedChats = HashSet() private val selectedUsers = HashSet() @@ -270,9 +269,8 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch override fun onSearchContactsFinished(obj: TdApi.Users) { log.debug("searchContactsFinished $obj") val ids = obj.userIds - searchedContactsIds.clear() if (ids.isNotEmpty()) { - searchedContactsIds.addAll(ids.toList()) + searchedContactsIds = ids.toMutableSet() app.runInUIThread { updateList() } } } @@ -280,9 +278,8 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch override fun onSearchChatsFinished(obj: TdApi.Chats) { log.debug("searchChatsFinished $obj") val ids = obj.chatIds - searchedChatsIds.clear() if (ids.isNotEmpty()) { - searchedChatsIds.addAll(ids.toList()) + searchedChatsIds = ids.toMutableSet() app.runInUIThread { updateList() } } } @@ -290,9 +287,8 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch override fun onSearchPublicChatsFinished(obj: TdApi.Chats) { log.debug("onSearchPublicChatsFinished $obj") val ids = obj.chatIds - searchedPublicChatsIds.clear() if (ids.isNotEmpty()) { - searchedPublicChatsIds.addAll(ids.toList()) + searchedPublicChatsIds = ids.toMutableSet() app.runInUIThread { updateList() } } }