show the repeatability related things only if an event is repeatable
This commit is contained in:
parent
f8dedf89a6
commit
c91390f3a1
|
@ -4,13 +4,22 @@ import android.app.Activity
|
|||
import android.support.v7.app.AlertDialog
|
||||
import android.view.LayoutInflater
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.helpers.DBHelper
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import kotlinx.android.synthetic.main.dialog_delete_event.view.*
|
||||
|
||||
class DeleteEventDialog(val activity: Activity, val eventIds: List<Int>, val callback: (allOccurrences: Boolean) -> Unit) : AlertDialog.Builder(activity) {
|
||||
class DeleteEventDialog(val activity: Activity, eventIds: List<Int>, val callback: (allOccurrences: Boolean) -> Unit) : AlertDialog.Builder(activity) {
|
||||
val dialog: AlertDialog?
|
||||
|
||||
init {
|
||||
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_delete_event, null)
|
||||
val events = DBHelper.newInstance(activity).getEventsWithIds(eventIds)
|
||||
val hasRepeatableEvent = events.any { it.repeatInterval > 0 }
|
||||
|
||||
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_delete_event, null).apply {
|
||||
delete_event_repeat_description.beVisibleIf(hasRepeatableEvent)
|
||||
delete_event_radio_view.beVisibleIf(hasRepeatableEvent)
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.yes, { dialog, which -> dialogConfirmed() })
|
||||
|
|
|
@ -385,6 +385,12 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
return events
|
||||
}
|
||||
|
||||
fun getEventsWithIds(ids: List<Int>): List<Event> {
|
||||
val args = TextUtils.join(", ", ids)
|
||||
val selection = "$MAIN_TABLE_NAME.$COL_ID IN ($args)"
|
||||
return getEvents(selection)
|
||||
}
|
||||
|
||||
fun getEventsAtReboot(): List<Event> {
|
||||
val selection = "$COL_REMINDER_MINUTES != -1 AND ($COL_START_TS > ? OR $COL_REPEAT_INTERVAL != 0)"
|
||||
val selectionArgs = arrayOf(DateTime.now().seconds().toString())
|
||||
|
|
Loading…
Reference in New Issue