From 844dbf1e4ae357c15bf138b8d0982c431c435d3b Mon Sep 17 00:00:00 2001 From: Dmitriy Ruban Date: Mon, 23 Dec 2019 16:09:52 +0200 Subject: [PATCH] refactor --- OsmAnd-telegram/res/values/strings.xml | 2 +- .../src/net/osmand/telegram/helpers/LocationMessages.kt | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/OsmAnd-telegram/res/values/strings.xml b/OsmAnd-telegram/res/values/strings.xml index ec720fe402..68efa96410 100644 --- a/OsmAnd-telegram/res/values/strings.xml +++ b/OsmAnd-telegram/res/values/strings.xml @@ -1,7 +1,7 @@ Time after which buffered location messages will be deleted - Buffer time + Buffer expiration time Select time zone to show in your location messages. Time zone Units & formats diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/LocationMessages.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/LocationMessages.kt index 20fa155f0b..065c7489d2 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/LocationMessages.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/LocationMessages.kt @@ -152,10 +152,10 @@ class LocationMessages(val app: TelegramApplication) { private fun removeOldBufferedMessages() { val currentTime = System.currentTimeMillis() if (this.bufferedMessages.isNotEmpty() && isTimeToDelete(currentTime)) { - val bufferTime = app.settings.bufferTime * 1000 + val bufferExpirationTime = app.settings.bufferTime * 1000 val messages = this.bufferedMessages.toMutableList() val expiredList = messages.filter { - currentTime - it.time > bufferTime + currentTime - it.time > bufferExpirationTime } expiredList.forEach { message -> dbHelper.removeBufferedMessage(message) @@ -168,7 +168,9 @@ class LocationMessages(val app: TelegramApplication) { private fun isTimeToDelete(currentTime: Long) = if (lastRemoveTime != null) { currentTime - lastRemoveTime!! > 60000L - } else true + } else { + true + } private fun readBufferedMessages() { this.bufferedMessages = dbHelper.getBufferedMessages()