rename CalDAVEventsHandler to CalDAVHandler

This commit is contained in:
tibbi 2017-08-22 14:08:53 +02:00
parent a5d11ec1fd
commit a0738b9306
8 changed files with 19 additions and 20 deletions

View File

@ -388,7 +388,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
event_caldav_calendar_holder.beVisible()
event_caldav_calendar_divider.beVisible()
val calendars = CalDAVEventsHandler(applicationContext).getCalDAVCalendars().filter {
val calendars = CalDAVHandler(applicationContext).getCalDAVCalendars().filter {
it.canWrite() && config.getSyncedCalendarIdsAsList().contains(it.id.toString())
}
updateCurrentCalendarInfo(getCalendarWithId(calendars, getCalendarId()))

View File

@ -14,7 +14,7 @@ import com.simplemobiletools.calendar.dialogs.CustomEventReminderDialog
import com.simplemobiletools.calendar.dialogs.SelectCalendarsDialog
import com.simplemobiletools.calendar.dialogs.SnoozePickerDialog
import com.simplemobiletools.calendar.extensions.*
import com.simplemobiletools.calendar.helpers.CalDAVEventsHandler
import com.simplemobiletools.calendar.helpers.CalDAVHandler
import com.simplemobiletools.calendar.helpers.FONT_SIZE_LARGE
import com.simplemobiletools.calendar.helpers.FONT_SIZE_MEDIUM
import com.simplemobiletools.calendar.helpers.FONT_SIZE_SMALL
@ -126,7 +126,7 @@ class SettingsActivity : SimpleActivity() {
config.caldavSync = false
settings_manage_synced_calendars_holder.beGone()
config.getSyncedCalendarIdsAsList().forEach {
CalDAVEventsHandler(applicationContext).deleteCalDAVCalendarEvents(it.toLong())
CalDAVHandler(applicationContext).deleteCalDAVCalendarEvents(it.toLong())
}
}
}
@ -151,11 +151,11 @@ class SettingsActivity : SimpleActivity() {
dbHelper.insertEventType(eventType)
}
}
CalDAVEventsHandler(applicationContext).refreshCalendars {}
CalDAVHandler(applicationContext).refreshCalendars {}
}
oldCalendarIds.filter { !newCalendarIds.contains(it) }.forEach {
CalDAVEventsHandler(applicationContext).deleteCalDAVCalendarEvents(it.toLong())
CalDAVHandler(applicationContext).deleteCalDAVCalendarEvents(it.toLong())
val eventId = dbHelper.getEventTypeIdWithCalDAVCalendarId(it.toInt())
dbHelper.deleteEventTypes(arrayListOf(eventId), true) {}
}

View File

@ -44,7 +44,7 @@ class EventTypeAdapter(val activity: SimpleActivity, val mItems: List<EventType>
textColor = activity.config.textColor
}
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
private val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
when (item.itemId) {
R.id.cab_delete -> askConfirmDelete()
@ -133,7 +133,7 @@ class EventTypeAdapter(val activity: SimpleActivity, val mItems: List<EventType>
return itemView
}
fun viewClicked(multiSelector: MultiSelector, eventType: EventType, pos: Int) {
private fun viewClicked(multiSelector: MultiSelector, eventType: EventType, pos: Int) {
if (multiSelector.isSelectable) {
val isSelected = multiSelector.selectedPositions.contains(layoutPosition)
multiSelector.setSelected(this, !isSelected)

View File

@ -56,11 +56,10 @@ class NewEventTypeDialog(val activity: Activity, var eventType: EventType? = nul
eventType!!.title = title
val eventTypeId: Int
if (isNewEvent) {
eventTypeId = activity.dbHelper.insertEventType(eventType!!)
val eventTypeId = if (isNewEvent) {
activity.dbHelper.insertEventType(eventType!!)
} else {
eventTypeId = activity.dbHelper.updateEventType(eventType!!)
activity.dbHelper.updateEventType(eventType!!)
}
if (eventTypeId != -1) {

View File

@ -8,7 +8,7 @@ import android.view.ViewGroup
import android.widget.RelativeLayout
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.calendar.helpers.CalDAVEventsHandler
import com.simplemobiletools.calendar.helpers.CalDAVHandler
import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.calendar_item_account.view.*
import kotlinx.android.synthetic.main.calendar_item_calendar.view.*
@ -21,7 +21,7 @@ class SelectCalendarsDialog(val activity: Activity, val callback: () -> Unit) :
init {
val ids = activity.config.getSyncedCalendarIdsAsList()
val calendars = CalDAVEventsHandler(activity).getCalDAVCalendars()
val calendars = CalDAVHandler(activity).getCalDAVCalendars()
val sorted = calendars.sortedWith(compareBy({ it.accountName }, { it.displayName }))
sorted.forEach {
if (prevAccount != it.accountName) {

View File

@ -235,11 +235,11 @@ fun Context.getNewEventTimestampFromCode(dayCode: String) = Formatter.getLocalDa
fun Context.getCurrentOffset() = SimpleDateFormat("Z", Locale.getDefault()).format(Date())
fun Context.getSyncedCalDAVCalendars() = CalDAVEventsHandler(this).getCalDAVCalendars(config.caldavSyncedCalendarIDs)
fun Context.getSyncedCalDAVCalendars() = CalDAVHandler(this).getCalDAVCalendars(config.caldavSyncedCalendarIDs)
fun Context.recheckCalDAVCalendars(callback: () -> Unit) {
if (config.caldavSync) {
CalDAVEventsHandler(this).refreshCalendars(callback)
CalDAVHandler(this).refreshCalendars(callback)
}
}

View File

@ -17,11 +17,11 @@ import com.simplemobiletools.commons.extensions.getLongValue
import com.simplemobiletools.commons.extensions.getStringValue
import java.util.*
class CalDAVEventsHandler(val context: Context) {
class CalDAVHandler(val context: Context) {
fun refreshCalendars(callback: () -> Unit) {
getCalDAVCalendars(context.config.caldavSyncedCalendarIDs).forEach {
val eventTypeId = context.dbHelper.getEventTypeIdWithTitle("${it.displayName} (${it.accountName})")
CalDAVEventsHandler(context).fetchCalDAVCalendarEvents(it.id, eventTypeId)
CalDAVHandler(context).fetchCalDAVCalendarEvents(it.id, eventTypeId)
}
context.scheduleCalDAVSync(true)
callback()

View File

@ -201,7 +201,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
context.scheduleReminder(event, this)
if (addToCalDAV && event.source != SOURCE_SIMPLE_CALENDAR) {
CalDAVEventsHandler(context).insertCalDAVEvent(event)
CalDAVHandler(context).insertCalDAVEvent(event)
}
callback(event.id)
@ -224,7 +224,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
context.updateWidgets()
context.scheduleReminder(event, this)
if (updateAtCalDAV && event.source != SOURCE_SIMPLE_CALENDAR) {
CalDAVEventsHandler(context).updateCalDAVEvent(event)
CalDAVHandler(context).updateCalDAVEvent(event)
}
callback()
}
@ -381,7 +381,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
if (deleteFromCalDAV) {
events.forEach {
CalDAVEventsHandler(context).deleteCalDAVEvent(it)
CalDAVHandler(context).deleteCalDAVEvent(it)
}
}