diff --git a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt index b35d004c43..227215c03c 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt @@ -998,12 +998,12 @@ class TelegramSettings(private val app: TelegramApplication) { } fun calcLivePeriod(periods: LinkedList): Long { - val copy = periods.toLongArray() - copy.sort() - return if (copy.size % 2 == 0) { - (copy[copy.size / 2] + copy[copy.size / 2 - 1]) / 2 + val sortedPeriods = periods.toLongArray() + sortedPeriods.sort() + return if (sortedPeriods.size % 2 == 0) { + (sortedPeriods[sortedPeriods.size / 2] + sortedPeriods[sortedPeriods.size / 2 - 1]) / 2 } else { - copy[copy.size / 2] + sortedPeriods[sortedPeriods.size / 2] } } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt index 493f376c36..8f439b79d7 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt @@ -44,7 +44,7 @@ private const val MY_LOCATION_TAB_POS = 0 private const val LIVE_NOW_TAB_POS = 1 private const val TIMELINE_TAB_POS = 2 -class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListener, TelegramIncomingMessagesListener, DataSetListener { +class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListener, TelegramIncomingMessagesListener { private val log = PlatformUtil.getLog(MainActivity::class.java) @@ -486,7 +486,7 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene } } - override fun onDataSetChanged() { + fun onDataSetChanged() { viewPager.adapter?.notifyDataSetChanged() } @@ -522,7 +522,3 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene } } } - -interface DataSetListener { - fun onDataSetChanged() -} diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt index d3f07aea04..9596d6114a 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt @@ -856,7 +856,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener { } else { settings.shareLocationToChat(lastChat.chat.id, true, lastChat.time) app.shareLocationHelper.startSharingLocation() - (activity as DataSetListener).onDataSetChanged() + (activity as MainActivity).onDataSetChanged() } }