creating some event related database tables
This commit is contained in:
parent
b1badc5e1a
commit
7ae700db34
|
@ -0,0 +1,47 @@
|
|||
package com.simplemobiletools.calendar.pro
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import com.simplemobiletools.calendar.pro.interfaces.EventRepetitionExceptionsDao
|
||||
import com.simplemobiletools.calendar.pro.interfaces.EventRepetitionsDao
|
||||
import com.simplemobiletools.calendar.pro.interfaces.EventTypesDao
|
||||
import com.simplemobiletools.calendar.pro.interfaces.EventsDao
|
||||
import com.simplemobiletools.calendar.pro.models.Event
|
||||
import com.simplemobiletools.calendar.pro.models.EventRepetition
|
||||
import com.simplemobiletools.calendar.pro.models.EventRepetitionException
|
||||
import com.simplemobiletools.calendar.pro.models.EventType
|
||||
|
||||
@Database(entities = [Event::class, EventType::class, EventRepetition::class, EventRepetitionException::class], version = 1)
|
||||
abstract class EventsDatabase : RoomDatabase() {
|
||||
|
||||
abstract fun EventsDao(): EventsDao
|
||||
|
||||
abstract fun EventTypesDao(): EventTypesDao
|
||||
|
||||
abstract fun EventRepetitionsDao(): EventRepetitionsDao
|
||||
|
||||
abstract fun EventRepetitionExceptionsDao(): EventRepetitionExceptionsDao
|
||||
|
||||
companion object {
|
||||
private var db: EventsDatabase? = null
|
||||
|
||||
fun getInstance(context: Context): EventsDatabase {
|
||||
if (db == null) {
|
||||
synchronized(EventsDatabase::class) {
|
||||
if (db == null) {
|
||||
db = Room.databaseBuilder(context.applicationContext, EventsDatabase::class.java, "events.db")
|
||||
.build()
|
||||
db!!.openHelper.setWriteAheadLoggingEnabled(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
return db!!
|
||||
}
|
||||
|
||||
fun destroyInstance() {
|
||||
db = null
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,12 +21,17 @@ import android.widget.LinearLayout
|
|||
import android.widget.TextView
|
||||
import androidx.core.app.AlarmManagerCompat
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.simplemobiletools.calendar.pro.EventsDatabase
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.activities.EventActivity
|
||||
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.calendar.pro.activities.SnoozeReminderActivity
|
||||
import com.simplemobiletools.calendar.pro.helpers.*
|
||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.pro.interfaces.EventRepetitionExceptionsDao
|
||||
import com.simplemobiletools.calendar.pro.interfaces.EventRepetitionsDao
|
||||
import com.simplemobiletools.calendar.pro.interfaces.EventTypesDao
|
||||
import com.simplemobiletools.calendar.pro.interfaces.EventsDao
|
||||
import com.simplemobiletools.calendar.pro.models.*
|
||||
import com.simplemobiletools.calendar.pro.receivers.CalDAVSyncReceiver
|
||||
import com.simplemobiletools.calendar.pro.receivers.NotificationReceiver
|
||||
|
@ -43,6 +48,14 @@ import java.util.*
|
|||
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||
|
||||
val Context.eventsDB: EventsDao get() = EventsDatabase.getInstance(applicationContext).EventsDao()
|
||||
|
||||
val Context.eventTypesDB: EventTypesDao get() = EventsDatabase.getInstance(applicationContext).EventTypesDao()
|
||||
|
||||
val Context.eventRepetitionssDB: EventRepetitionsDao get() = EventsDatabase.getInstance(applicationContext).EventRepetitionsDao()
|
||||
|
||||
val Context.eventRepetitionExceptionsDB: EventRepetitionExceptionsDao get() = EventsDatabase.getInstance(applicationContext).EventRepetitionExceptionsDao()
|
||||
|
||||
val Context.dbHelper: DBHelper get() = DBHelper.newInstance(applicationContext)
|
||||
|
||||
fun Context.updateWidgets() {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package com.simplemobiletools.calendar.pro.interfaces
|
||||
|
||||
import androidx.room.Dao
|
||||
|
||||
@Dao
|
||||
interface EventRepetitionExceptionsDao {
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.simplemobiletools.calendar.pro.interfaces
|
||||
|
||||
import androidx.room.Dao
|
||||
|
||||
@Dao
|
||||
interface EventRepetitionsDao {
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.simplemobiletools.calendar.pro.interfaces
|
||||
|
||||
import androidx.room.Dao
|
||||
|
||||
@Dao
|
||||
interface EventTypesDao {
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.simplemobiletools.calendar.pro.interfaces
|
||||
|
||||
import androidx.room.Dao
|
||||
|
||||
@Dao
|
||||
interface EventsDao {
|
||||
|
||||
}
|
Loading…
Reference in New Issue