scroll to the current time zone at the selector by default
This commit is contained in:
parent
393abbaf90
commit
2796cfdfe4
|
@ -1186,6 +1186,7 @@ class EventActivity : SimpleActivity() {
|
|||
|
||||
private fun setupTimeZone() {
|
||||
Intent(this, SelectTimeZoneActivity::class.java).apply {
|
||||
putExtra(CURRENT_TIME_ZONE, mEvent.getTimeZoneString())
|
||||
startActivityForResult(this, SELECT_TIME_ZONE_INTENT)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import androidx.appcompat.widget.SearchView
|
|||
import androidx.core.view.MenuItemCompat
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.adapters.SelectTimeZoneAdapter
|
||||
import com.simplemobiletools.calendar.pro.helpers.CURRENT_TIME_ZONE
|
||||
import com.simplemobiletools.calendar.pro.helpers.TIME_ZONE
|
||||
import com.simplemobiletools.calendar.pro.helpers.getAllTimeZones
|
||||
import com.simplemobiletools.calendar.pro.models.MyTimeZone
|
||||
|
@ -18,13 +19,14 @@ import java.util.*
|
|||
|
||||
class SelectTimeZoneActivity : SimpleActivity() {
|
||||
private var mSearchMenuItem: MenuItem? = null
|
||||
private val allTimeZones = getAllTimeZones()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_select_time_zone)
|
||||
title = ""
|
||||
|
||||
SelectTimeZoneAdapter(this, getAllTimeZones()) {
|
||||
SelectTimeZoneAdapter(this, allTimeZones) {
|
||||
val data = Intent()
|
||||
data.putExtra(TIME_ZONE, it as MyTimeZone)
|
||||
setResult(RESULT_OK, data)
|
||||
|
@ -32,6 +34,12 @@ class SelectTimeZoneActivity : SimpleActivity() {
|
|||
}.apply {
|
||||
select_time_zone_list.adapter = this
|
||||
}
|
||||
|
||||
val currentTimeZone = intent.getStringExtra(CURRENT_TIME_ZONE) ?: TimeZone.getDefault().id
|
||||
val pos = allTimeZones.indexOfFirst { it.zoneName.equals(currentTimeZone, true) }
|
||||
if (pos != -1) {
|
||||
select_time_zone_list.scrollToPosition(pos)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
@ -74,7 +82,7 @@ class SelectTimeZoneActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun searchQueryChanged(text: String) {
|
||||
val timeZones = getAllTimeZones().filter {
|
||||
val timeZones = allTimeZones.filter {
|
||||
it.zoneName.toLowerCase(Locale.getDefault()).contains(text.toLowerCase(Locale.getDefault()))
|
||||
}.toMutableList() as ArrayList<MyTimeZone>
|
||||
(select_time_zone_list.adapter as? SelectTimeZoneAdapter)?.updateTimeZones(timeZones)
|
||||
|
|
|
@ -18,6 +18,7 @@ const val VIEW_TO_OPEN = "view_to_open"
|
|||
const val SHORTCUT_NEW_EVENT = "shortcut_new_event"
|
||||
const val REGULAR_EVENT_TYPE_ID = 1L
|
||||
const val TIME_ZONE = "time_zone"
|
||||
const val CURRENT_TIME_ZONE = "current_time_zone"
|
||||
|
||||
const val MONTHLY_VIEW = 1
|
||||
const val YEARLY_VIEW = 2
|
||||
|
|
Loading…
Reference in New Issue