From 2b0b2b44478d538c6ff5c62d5820115a0b1b9739 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 13 Jul 2018 14:16:01 +0300 Subject: [PATCH] remove updateChatTitles --- .../net/osmand/telegram/helpers/TelegramHelper.kt | 13 +------------ .../src/net/osmand/telegram/ui/MainActivity.kt | 2 +- .../net/osmand/telegram/ui/SetTimeDialogFragment.kt | 5 ----- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt index 748537acb9..d317289b6d 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt @@ -49,7 +49,6 @@ class TelegramHelper private constructor() { private val secretChats = ConcurrentHashMap() private val chats = ConcurrentHashMap() - private val chatTitles = ConcurrentHashMap() private val chatList = TreeSet() private val chatLiveMessages = ConcurrentHashMap() @@ -98,7 +97,7 @@ class TelegramHelper private constructor() { } } - fun getChatTitles() = chatTitles.toList() + fun getChatIds() = chats.keys().toList() fun getChat(id: Long) = chats[id] @@ -130,13 +129,6 @@ class TelegramHelper private constructor() { fun getSupergroupFullInfo(id: Int) = supergroupsFullInfo[id] - private fun updateChatIds() { - chatTitles.clear() - for (chatEntry in chats.entries) { - chatTitles[chatEntry.value.title] = chatEntry.key - } - } - private fun isChannel(chat: TdApi.Chat): Boolean { return chat.type is TdApi.ChatTypeSupergroup && (chat.type as TdApi.ChatTypeSupergroup).isChannel } @@ -346,7 +338,6 @@ class TelegramHelper private constructor() { return } } - updateChatIds() listener?.onTelegramChatsRead() } @@ -756,7 +747,6 @@ class TelegramHelper private constructor() { chat.order = 0 setChatOrder(chat, order) } - updateChatIds() listener?.onTelegramChatsChanged() } TdApi.UpdateChatTitle.CONSTRUCTOR -> { @@ -766,7 +756,6 @@ class TelegramHelper private constructor() { synchronized(chat) { chat.title = updateChat.title } - updateChatIds() listener?.onTelegramChatChanged(chat) } } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt index cb85f69138..5b822397f3 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt @@ -258,7 +258,7 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene } private fun removeNonexistingChatsFromSettings() { - val presentChatTitles = telegramHelper.getChatTitles() + val presentChatTitles = telegramHelper.getChatIds() settings.removeNonexistingChats(presentChatTitles) } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/SetTimeDialogFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/SetTimeDialogFragment.kt index c22169b08b..c534b0c897 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/SetTimeDialogFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/SetTimeDialogFragment.kt @@ -17,7 +17,6 @@ import net.osmand.telegram.TelegramApplication import net.osmand.telegram.helpers.ShareLocationHelper import net.osmand.telegram.helpers.TelegramUiHelper import net.osmand.telegram.ui.SetTimeDialogFragment.SetTimeListAdapter.ChatViewHolder -import net.osmand.telegram.utils.AndroidUtils import org.drinkless.td.libcore.telegram.TdApi import java.util.concurrent.TimeUnit @@ -78,7 +77,6 @@ class SetTimeDialogFragment : DialogFragment() { text = getString(R.string.shared_string_share) setOnClickListener { Toast.makeText(context, "Share", Toast.LENGTH_SHORT).show() - } } @@ -148,9 +146,6 @@ class SetTimeDialogFragment : DialogFragment() { if (seconds >= ShareLocationHelper.MIN_LOCATION_MESSAGE_LIVE_PERIOD_SEC) { if (id != null) { chatIdsToDuration[id] = seconds - app.settings.shareLocationToChat(id, true) - app.shareLocationHelper.startSharingLocation() - } else { chatIdsToDuration.keys.forEach { chatIdsToDuration[it] = seconds