Merge pull request #8192 from osmandapp/Suggested_List

Suggested list
This commit is contained in:
max-klaus 2020-01-08 15:06:06 +03:00 committed by GitHub
commit a61bc4343a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 refreshPages() {
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).refreshPages()
}
}