allow drag selecting timezones and alarms

This commit is contained in:
tibbi 2018-03-08 21:23:16 +01:00
parent 7ef63b76e4
commit 05eae929d1
2 changed files with 8 additions and 4 deletions

View File

@ -51,10 +51,12 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
alarms = context!!.dbHelper.getAlarms()
val currAdapter = view.alarms_list.adapter
if (currAdapter == null) {
val alarmsAdapter = AlarmsAdapter(activity as SimpleActivity, alarms, this, view.alarms_list) {
AlarmsAdapter(activity as SimpleActivity, alarms, this, view.alarms_list) {
openEditAlarm(it as Alarm)
}.apply {
setupDragListener(true)
view.alarms_list.adapter = this
}
view.alarms_list.adapter = alarmsAdapter
} else {
(currAdapter as AlarmsAdapter).updateItems(alarms)
}

View File

@ -121,12 +121,14 @@ class ClockFragment : Fragment() {
val timeZones = context!!.getAllTimeZonesModified().filter { selectedTimeZoneIDs.contains(it.id) } as ArrayList<MyTimeZone>
val currAdapter = view.time_zones_list.adapter
if (currAdapter == null) {
val timeZonesAdapter = TimeZonesAdapter(activity as SimpleActivity, timeZones, view.time_zones_list) {
TimeZonesAdapter(activity as SimpleActivity, timeZones, view.time_zones_list) {
EditTimeZoneDialog(activity as SimpleActivity, it as MyTimeZone) {
updateTimeZones()
}
}.apply {
setupDragListener(true)
view.time_zones_list.adapter = this
}
view.time_zones_list.adapter = timeZonesAdapter
} else {
(currAdapter as TimeZonesAdapter).updateItems(timeZones)
}