corrections

This commit is contained in:
Dmitriy Ruban 2020-01-08 13:56:02 +02:00
parent 5a0811967f
commit b2c19db626
3 changed files with 8 additions and 12 deletions

View file

@ -998,12 +998,12 @@ class TelegramSettings(private val app: TelegramApplication) {
}
fun calcLivePeriod(periods: LinkedList<Long>): 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]
}
}

View file

@ -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()
}

View file

@ -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()
}
}