implementing some adapter deleting
This commit is contained in:
parent
921873f9a6
commit
e0078d8f2a
2 changed files with 19 additions and 13 deletions
|
@ -7,6 +7,7 @@ import android.widget.RelativeLayout
|
|||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.clock.extensions.dbHelper
|
||||
import com.simplemobiletools.clock.extensions.getFormattedTime
|
||||
import com.simplemobiletools.clock.interfaces.ToggleAlarmInterface
|
||||
import com.simplemobiletools.clock.models.Alarm
|
||||
|
@ -67,16 +68,18 @@ class AlarmsAdapter(activity: SimpleActivity, var alarms: ArrayList<Alarm>, val
|
|||
|
||||
private fun deleteItems() {
|
||||
val alarmsToRemove = ArrayList<Alarm>()
|
||||
/*selectedPositions.sortedDescending().forEach {
|
||||
val alarm = alarms[it]
|
||||
alarmsToRemove.add(alarm)
|
||||
val positions = getSelectedItemPositions()
|
||||
getSelectedItems().forEach {
|
||||
alarmsToRemove.add(it)
|
||||
}
|
||||
|
||||
alarms.removeAll(alarmsToRemove)
|
||||
removeSelectedItems()
|
||||
activity.dbHelper.deleteAlarms(alarmsToRemove)*/
|
||||
removeSelectedItems(positions)
|
||||
activity.dbHelper.deleteAlarms(alarmsToRemove)
|
||||
}
|
||||
|
||||
private fun getSelectedItems() = alarms.filter { selectedKeys.contains(it.id) } as ArrayList<Alarm>
|
||||
|
||||
private fun setupView(view: View, alarm: Alarm) {
|
||||
val isSelected = selectedKeys.contains(alarm.id)
|
||||
view.apply {
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.clock.extensions.getFormattedDate
|
||||
import com.simplemobiletools.clock.extensions.getFormattedTime
|
||||
import com.simplemobiletools.clock.models.MyTimeZone
|
||||
|
@ -69,22 +70,24 @@ class TimeZonesAdapter(activity: SimpleActivity, var timeZones: ArrayList<MyTime
|
|||
}
|
||||
|
||||
private fun deleteItems() {
|
||||
val timeZonesToRemove = ArrayList<MyTimeZone>()
|
||||
val timeZoneIDsToRemove = ArrayList<String>()
|
||||
/*selectedPositions.sortedDescending().forEach {
|
||||
val timeZone = timeZones[it]
|
||||
timeZonesToRemove.add(timeZone)
|
||||
timeZoneIDsToRemove.add(timeZone.id.toString())
|
||||
val timeZonesToRemove = ArrayList<MyTimeZone>(selectedKeys.size)
|
||||
val timeZoneIDsToRemove = ArrayList<String>(selectedKeys.size)
|
||||
val positions = getSelectedItemPositions()
|
||||
getSelectedItems().forEach {
|
||||
timeZonesToRemove.add(it)
|
||||
timeZoneIDsToRemove.add(it.id.toString())
|
||||
}
|
||||
|
||||
timeZones.removeAll(timeZonesToRemove)
|
||||
removeSelectedItems()
|
||||
removeSelectedItems(positions)
|
||||
|
||||
val selectedTimeZones = activity.config.selectedTimeZones
|
||||
val newTimeZones = selectedTimeZones.filter { !timeZoneIDsToRemove.contains(it) }.toHashSet()
|
||||
activity.config.selectedTimeZones = newTimeZones*/
|
||||
activity.config.selectedTimeZones = newTimeZones
|
||||
}
|
||||
|
||||
private fun getSelectedItems() = timeZones.filter { selectedKeys.contains(it.id) } as ArrayList<MyTimeZone>
|
||||
|
||||
private fun setupView(view: View, timeZone: MyTimeZone) {
|
||||
val currTimeZone = TimeZone.getTimeZone(timeZone.zoneName)
|
||||
val calendar = Calendar.getInstance(currTimeZone)
|
||||
|
|
Loading…
Reference in a new issue