renaming EventTypesHelper to EventsHelper

This commit is contained in:
tibbi 2018-11-14 18:39:50 +01:00
parent 7ed9a42575
commit 977b137a9b
17 changed files with 49 additions and 49 deletions

View file

@ -648,7 +648,7 @@ class EventActivity : SimpleActivity() {
event_caldav_calendar_email.text = currentCalendar.accountName
Thread {
val calendarColor = EventTypesHelper().getEventTypeWithCalDAVCalendarId(applicationContext, currentCalendar.id)?.color
val calendarColor = EventsHelper().getEventTypeWithCalDAVCalendarId(applicationContext, currentCalendar.id)?.color
?: currentCalendar.color
runOnUiThread {
@ -732,7 +732,7 @@ class EventActivity : SimpleActivity() {
val newEventType = if (!config.caldavSync || config.lastUsedCaldavCalendarId == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) {
mEventTypeId
} else {
EventTypesHelper().getEventTypeWithCalDAVCalendarId(applicationContext, mEventCalendarId)?.id ?: config.lastUsedLocalEventTypeId
EventsHelper().getEventTypeWithCalDAVCalendarId(applicationContext, mEventCalendarId)?.id ?: config.lastUsedLocalEventTypeId
}
val newSource = if (!config.caldavSync || mEventCalendarId == STORED_LOCALLY_ONLY) {
@ -785,7 +785,7 @@ class EventActivity : SimpleActivity() {
private fun storeEvent(wasRepeatable: Boolean) {
if (mEvent.id == 0L || mEvent.id == null) {
EventTypesHelper().insertEvent(applicationContext, this, mEvent, true) {
EventsHelper().insertEvent(applicationContext, this, mEvent, true) {
if (DateTime.now().isAfter(mEventStartDateTime.millis)) {
if (mEvent.repeatInterval == 0 && mEvent.getReminders().isNotEmpty()) {
notifyEvent(mEvent)
@ -826,7 +826,7 @@ class EventActivity : SimpleActivity() {
repeatLimit = 0
}
EventTypesHelper().insertEvent(applicationContext, this, mEvent, true) {
EventsHelper().insertEvent(applicationContext, this, mEvent, true) {
finish()
}
}.start()

View file

@ -112,7 +112,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
updateViewPager()
}
EventTypesHelper().getEventTypes(this) {
EventsHelper().getEventTypes(this) {
val newShouldFilterBeVisible = it.size > 1 || config.displayEventTypes.isEmpty()
if (newShouldFilterBeVisible != mShouldFilterBeVisible) {
mShouldFilterBeVisible = newShouldFilterBeVisible
@ -402,10 +402,10 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
toast(R.string.importing)
Thread {
val holidays = getString(R.string.holidays)
var eventTypeId = EventTypesHelper().getEventTypeIdWithTitle(applicationContext, holidays)
var eventTypeId = EventsHelper().getEventTypeIdWithTitle(applicationContext, holidays)
if (eventTypeId == -1L) {
val eventType = EventType(null, holidays, resources.getColor(R.color.default_holidays_color))
eventTypeId = EventTypesHelper().insertOrUpdateEventTypeSync(applicationContext, eventType)
eventTypeId = EventsHelper().insertOrUpdateEventTypeSync(applicationContext, eventType)
}
val result = IcsImporter(this).importEvents(it as String, eventTypeId, 0, false)
@ -505,7 +505,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
eventType = eventTypeId, source = source, lastUpdated = lastUpdated)
if (!importIDs.contains(contactId)) {
EventTypesHelper().insertEvent(applicationContext, null, event, false) {
EventsHelper().insertEvent(applicationContext, null, event, false) {
eventsAdded++
}
}
@ -528,20 +528,20 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private fun getBirthdaysEventTypeId(): Long {
val birthdays = getString(R.string.birthdays)
var eventTypeId = EventTypesHelper().getEventTypeIdWithTitle(applicationContext, birthdays)
var eventTypeId = EventsHelper().getEventTypeIdWithTitle(applicationContext, birthdays)
if (eventTypeId == -1L) {
val eventType = EventType(null, birthdays, resources.getColor(R.color.default_birthdays_color))
eventTypeId = EventTypesHelper().insertOrUpdateEventTypeSync(applicationContext, eventType)
eventTypeId = EventsHelper().insertOrUpdateEventTypeSync(applicationContext, eventType)
}
return eventTypeId
}
private fun getAnniversariesEventTypeId(): Long {
val anniversaries = getString(R.string.anniversaries)
var eventTypeId = EventTypesHelper().getEventTypeIdWithTitle(applicationContext, anniversaries)
var eventTypeId = EventsHelper().getEventTypeIdWithTitle(applicationContext, anniversaries)
if (eventTypeId == -1L) {
val eventType = EventType(null, anniversaries, resources.getColor(R.color.default_anniversaries_color))
eventTypeId = EventTypesHelper().insertOrUpdateEventTypeSync(applicationContext, eventType)
eventTypeId = EventsHelper().insertOrUpdateEventTypeSync(applicationContext, eventType)
}
return eventTypeId
}

View file

@ -6,7 +6,7 @@ import android.view.MenuItem
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.adapters.ManageEventTypesAdapter
import com.simplemobiletools.calendar.pro.dialogs.EditEventTypeDialog
import com.simplemobiletools.calendar.pro.helpers.EventTypesHelper
import com.simplemobiletools.calendar.pro.helpers.EventsHelper
import com.simplemobiletools.calendar.pro.interfaces.DeleteEventTypesListener
import com.simplemobiletools.calendar.pro.models.EventType
import com.simplemobiletools.commons.extensions.toast
@ -30,7 +30,7 @@ class ManageEventTypesActivity : SimpleActivity(), DeleteEventTypesListener {
}
private fun getEventTypes() {
EventTypesHelper().getEventTypes(this) {
EventsHelper().getEventTypes(this) {
val adapter = ManageEventTypesAdapter(this, it, this, manage_event_types_list) {
showEventTypeDialog(it as EventType)
}
@ -60,7 +60,7 @@ class ManageEventTypesActivity : SimpleActivity(), DeleteEventTypesListener {
}
Thread {
EventTypesHelper().deleteEventTypes(applicationContext, eventTypes, deleteEvents)
EventsHelper().deleteEventTypes(applicationContext, eventTypes, deleteEvents)
}.start()
return true
}

View file

@ -89,11 +89,11 @@ class SettingsActivity : SimpleActivity() {
private fun checkPrimaryColor() {
if (config.primaryColor != mStoredPrimaryColor) {
Thread {
val eventTypes = EventTypesHelper().getEventTypesSync(this)
val eventTypes = EventsHelper().getEventTypesSync(this)
if (eventTypes.filter { it.caldavCalendarId == 0 }.size == 1) {
val eventType = eventTypes.first { it.caldavCalendarId == 0 }
eventType.color = config.primaryColor
EventTypesHelper().insertOrUpdateEventTypeSync(applicationContext, eventType)
EventsHelper().insertOrUpdateEventTypeSync(applicationContext, eventType)
}
}.start()
}
@ -208,13 +208,13 @@ class SettingsActivity : SimpleActivity() {
Thread {
if (newCalendarIds.isNotEmpty()) {
val existingEventTypeNames = EventTypesHelper().getEventTypesSync(applicationContext).map { it.getDisplayTitle().toLowerCase() } as ArrayList<String>
val existingEventTypeNames = EventsHelper().getEventTypesSync(applicationContext).map { it.getDisplayTitle().toLowerCase() } as ArrayList<String>
getSyncedCalDAVCalendars().forEach {
val calendarTitle = it.getFullTitle()
if (!existingEventTypeNames.contains(calendarTitle.toLowerCase())) {
val eventType = EventType(null, it.displayName, it.color, it.id, it.displayName, it.accountName)
existingEventTypeNames.add(calendarTitle.toLowerCase())
EventTypesHelper().insertOrUpdateEventType(this, eventType)
EventsHelper().insertOrUpdateEventType(this, eventType)
}
}
CalDAVHandler(applicationContext).refreshCalendars(this) {}
@ -223,8 +223,8 @@ class SettingsActivity : SimpleActivity() {
val removedCalendarIds = oldCalendarIds.filter { !newCalendarIds.contains(it) }
removedCalendarIds.forEach {
CalDAVHandler(applicationContext).deleteCalDAVCalendarEvents(it.toLong())
EventTypesHelper().getEventTypeWithCalDAVCalendarId(applicationContext, it)?.apply {
EventTypesHelper().deleteEventTypes(applicationContext, arrayListOf(this), true)
EventsHelper().getEventTypeWithCalDAVCalendarId(applicationContext, it)?.apply {
EventsHelper().deleteEventTypes(applicationContext, arrayListOf(this), true)
}
}

View file

@ -5,7 +5,7 @@ import android.widget.ImageView
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.EventTypesHelper
import com.simplemobiletools.calendar.pro.helpers.EventsHelper
import com.simplemobiletools.calendar.pro.models.EventType
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.extensions.*
@ -58,7 +58,7 @@ class EditEventTypeDialog(val activity: Activity, var eventType: EventType? = nu
}
private fun eventTypeConfirmed(title: String, dialog: AlertDialog) {
val eventIdWithTitle = EventTypesHelper().getEventTypeIdWithTitle(activity, title)
val eventIdWithTitle = EventsHelper().getEventTypeIdWithTitle(activity, title)
var isEventTypeTitleTaken = isNewEvent && eventIdWithTitle != -1L
if (!isEventTypeTitleTaken) {
isEventTypeTitleTaken = !isNewEvent && eventType!!.id != eventIdWithTitle && eventIdWithTitle != -1L
@ -77,7 +77,7 @@ class EditEventTypeDialog(val activity: Activity, var eventType: EventType? = nu
eventType!!.caldavDisplayName = title
}
eventType!!.id = EventTypesHelper().insertOrUpdateEventTypeSync(activity, eventType!!)
eventType!!.id = EventsHelper().insertOrUpdateEventTypeSync(activity, eventType!!)
if (eventType!!.id != -1L) {
activity.runOnUiThread {

View file

@ -6,7 +6,7 @@ import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.adapters.FilterEventTypeAdapter
import com.simplemobiletools.calendar.pro.helpers.EventTypesHelper
import com.simplemobiletools.calendar.pro.helpers.EventsHelper
import com.simplemobiletools.commons.extensions.*
import kotlinx.android.synthetic.main.dialog_export_events.view.*
import java.io.File
@ -19,7 +19,7 @@ class ExportEventsDialog(val activity: SimpleActivity, val path: String, val cal
export_events_folder.text = activity.humanizePath(path)
export_events_filename.setText("${activity.getString(R.string.events)}_${activity.getCurrentFormattedDateTime()}")
EventTypesHelper().getEventTypes(activity) {
EventsHelper().getEventTypes(activity) {
val eventTypes = HashSet<String>()
it.mapTo(eventTypes) { it.id.toString() }

View file

@ -5,7 +5,7 @@ import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.adapters.FilterEventTypeAdapter
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.EventTypesHelper
import com.simplemobiletools.calendar.pro.helpers.EventsHelper
import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.dialog_filter_event_types.view.*
@ -14,7 +14,7 @@ class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> U
private val view = activity.layoutInflater.inflate(R.layout.dialog_filter_event_types, null)
init {
EventTypesHelper().getEventTypes(activity) {
EventsHelper().getEventTypes(activity) {
val displayEventTypes = activity.config.displayEventTypes
view.filter_event_types_list.adapter = FilterEventTypeAdapter(activity, it, displayEventTypes)

View file

@ -7,7 +7,7 @@ import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.eventTypesDB
import com.simplemobiletools.calendar.pro.helpers.DBHelper
import com.simplemobiletools.calendar.pro.helpers.EventTypesHelper
import com.simplemobiletools.calendar.pro.helpers.EventsHelper
import com.simplemobiletools.calendar.pro.helpers.IcsImporter
import com.simplemobiletools.calendar.pro.helpers.IcsImporter.ImportResult.*
import com.simplemobiletools.commons.extensions.setFillWithStroke
@ -34,7 +34,7 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
private fun initDialog() {
val isLastCaldavCalendarOK = config.caldavSync && config.getSyncedCalendarIdsAsList().contains(config.lastUsedCaldavCalendarId)
currEventTypeId = if (isLastCaldavCalendarOK) {
val lastUsedCalDAVCalendar = EventTypesHelper().getEventTypeWithCalDAVCalendarId(activity, config.lastUsedCaldavCalendarId)
val lastUsedCalDAVCalendar = EventsHelper().getEventTypeWithCalDAVCalendarId(activity, config.lastUsedCaldavCalendarId)
if (lastUsedCalDAVCalendar != null) {
currEventTypeCalDAVCalendarId = config.lastUsedCaldavCalendarId
lastUsedCalDAVCalendar.id!!

View file

@ -8,7 +8,7 @@ import android.widget.RadioGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.EventTypesHelper
import com.simplemobiletools.calendar.pro.helpers.EventsHelper
import com.simplemobiletools.calendar.pro.helpers.STORED_LOCALLY_ONLY
import com.simplemobiletools.calendar.pro.models.CalDAVCalendar
import com.simplemobiletools.commons.extensions.setFillWithStroke
@ -28,7 +28,7 @@ class SelectEventCalendarDialog(val activity: Activity, val calendars: List<CalD
Thread {
calendars.forEach {
val localEventType = EventTypesHelper().getEventTypeWithCalDAVCalendarId(activity, it.id)
val localEventType = EventsHelper().getEventTypeWithCalDAVCalendarId(activity, it.id)
if (localEventType != null) {
it.color = localEventType.color
}

View file

@ -7,7 +7,7 @@ import android.widget.RadioGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.EventTypesHelper
import com.simplemobiletools.calendar.pro.helpers.EventsHelper
import com.simplemobiletools.calendar.pro.models.EventType
import com.simplemobiletools.commons.extensions.hideKeyboard
import com.simplemobiletools.commons.extensions.setFillWithStroke
@ -31,7 +31,7 @@ class SelectEventTypeDialog(val activity: Activity, val currEventType: Long, val
val view = activity.layoutInflater.inflate(R.layout.dialog_select_radio_group, null) as ViewGroup
radioGroup = view.dialog_radio_group
EventTypesHelper().getEventTypes(activity) {
EventsHelper().getEventTypes(activity) {
eventTypes = it
activity.runOnUiThread {
eventTypes.filter { showCalDAVCalendars || it.caldavCalendarId == 0 }.forEach {

View file

@ -66,7 +66,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
EventTypesHelper().getEventTypes(activity!!) {
EventsHelper().getEventTypes(activity!!) {
it.map { eventTypeColors.put(it.id!!, it.color) }
}

View file

@ -26,12 +26,12 @@ class CalDAVHandler(val context: Context) {
fun refreshCalendars(activity: SimpleActivity? = null, callback: () -> Unit) {
val calDAVCalendars = getCalDAVCalendars(activity, context.config.caldavSyncedCalendarIDs)
for (calendar in calDAVCalendars) {
val localEventType = EventTypesHelper().getEventTypeWithCalDAVCalendarId(context, calendar.id) ?: continue
val localEventType = EventsHelper().getEventTypeWithCalDAVCalendarId(context, calendar.id) ?: continue
localEventType.apply {
title = calendar.displayName
caldavDisplayName = calendar.displayName
caldavEmail = calendar.accountName
EventTypesHelper().insertOrUpdateEventTypeSync(context, this)
EventsHelper().insertOrUpdateEventTypeSync(context, this)
}
CalDAVHandler(context).fetchCalDAVCalendarEvents(calendar.id, localEventType.id!!, activity)
@ -241,7 +241,7 @@ class CalDAVHandler(val context: Context) {
if (title.isNotEmpty()) {
importIdsMap[event.importId] = event
EventTypesHelper().insertEvent(context, null, event, false)
EventsHelper().insertEvent(context, null, event, false)
}
}
} while (cursor.moveToNext())

View file

@ -112,7 +112,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
}
}
EventTypesHelper().insertEvent(context, null, childEvent, false) {
EventsHelper().insertEvent(context, null, childEvent, false) {
val childEventId = it
val eventRepetitionException = EventRepetitionException(null, Formatter.getDayCodeFromTS(occurrenceTS), parentEventId)
callback(eventRepetitionException)
@ -342,7 +342,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
events = events
.asSequence()
.distinct()
.filterNot { EventTypesHelper().getEventRepetitionIgnoredOccurrences(context, it).contains(Formatter.getDayCodeFromTS(it.startTS)) }
.filterNot { EventsHelper().getEventRepetitionIgnoredOccurrences(context, it).contains(Formatter.getDayCodeFromTS(it.startTS)) }
.toMutableList() as ArrayList<Event>
callback(events)
}

View file

@ -8,7 +8,7 @@ import com.simplemobiletools.calendar.pro.models.Event
import com.simplemobiletools.calendar.pro.models.EventType
import java.util.*
class EventTypesHelper {
class EventsHelper {
fun getEventTypes(activity: Activity, callback: (notes: ArrayList<EventType>) -> Unit) {
Thread {
val eventTypes = activity.eventTypesDB.getEventTypes().toMutableList() as ArrayList<EventType>

View file

@ -92,7 +92,7 @@ class IcsExporter {
}
private fun fillIgnoredOccurrences(activity: BaseSimpleActivity, event: Event, out: BufferedWriter) {
EventTypesHelper().getEventRepetitionIgnoredOccurrences(activity, event).forEach {
EventsHelper().getEventRepetitionIgnoredOccurrences(activity, event).forEach {
out.writeLn("$EXDATE:$it")
}
}

View file

@ -41,7 +41,7 @@ class IcsImporter(val activity: SimpleActivity) {
fun importEvents(path: String, defaultEventTypeId: Long, calDAVCalendarId: Int, overrideFileEventTypes: Boolean): ImportResult {
try {
val eventTypes = EventTypesHelper().getEventTypesSync(activity)
val eventTypes = EventsHelper().getEventTypesSync(activity)
val existingEvents = activity.dbHelper.getEventsWithImportIds()
val eventsToInsert = ArrayList<Event>()
var prevLine = ""
@ -158,7 +158,7 @@ class IcsImporter(val activity: SimpleActivity) {
if (curRepeatExceptions.isEmpty()) {
eventsToInsert.add(event)
} else {
EventTypesHelper().insertEvent(activity, activity, event, true) {
EventsHelper().insertEvent(activity, activity, event, true) {
for (exceptionTS in curRepeatExceptions) {
activity.dbHelper.addEventRepeatException(it, exceptionTS, true)
}
@ -176,7 +176,7 @@ class IcsImporter(val activity: SimpleActivity) {
}
}
EventTypesHelper().insertEvents(activity, eventsToInsert, true)
EventsHelper().insertEvents(activity, eventsToInsert, true)
} catch (e: Exception) {
activity.showErrorToast(e, Toast.LENGTH_LONG)
eventsFailed++
@ -223,11 +223,11 @@ class IcsImporter(val activity: SimpleActivity) {
categories
}
val eventId = EventTypesHelper().getEventTypeIdWithTitle(activity, eventTypeTitle)
val eventId = EventsHelper().getEventTypeIdWithTitle(activity, eventTypeTitle)
curEventTypeId = if (eventId == -1L) {
val newTypeColor = if (curCategoryColor == -2) activity.resources.getColor(R.color.color_primary) else curCategoryColor
val eventType = EventType(null, eventTypeTitle, newTypeColor)
EventTypesHelper().insertOrUpdateEventTypeSync(activity, eventType)
EventsHelper().insertOrUpdateEventTypeSync(activity, eventType)
} else {
eventId
}

View file

@ -9,7 +9,7 @@ import com.simplemobiletools.calendar.pro.extensions.notifyEvent
import com.simplemobiletools.calendar.pro.extensions.scheduleNextEventReminder
import com.simplemobiletools.calendar.pro.extensions.updateListWidget
import com.simplemobiletools.calendar.pro.helpers.EVENT_ID
import com.simplemobiletools.calendar.pro.helpers.EventTypesHelper
import com.simplemobiletools.calendar.pro.helpers.EventsHelper
import com.simplemobiletools.calendar.pro.helpers.Formatter
class NotificationReceiver : BroadcastReceiver() {
@ -35,7 +35,7 @@ class NotificationReceiver : BroadcastReceiver() {
return
}
if (!EventTypesHelper().getEventRepetitionIgnoredOccurrences(context, event).contains(Formatter.getDayCodeFromTS(event.startTS))) {
if (!EventsHelper().getEventRepetitionIgnoredOccurrences(context, event).contains(Formatter.getDayCodeFromTS(event.startTS))) {
context.notifyEvent(event)
}
context.scheduleNextEventReminder(event, context.dbHelper)