From 55bf3e4b5b4af5baa3c230ca82f74988608971a3 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 6 Aug 2019 00:49:58 -0700 Subject: Format kotlin --- .../main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt | 5 ++++- app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt | 16 ++++++++++------ app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt | 3 ++- .../kotlin/com/pitchedapps/frost/db/NotificationDb.kt | 16 +++++++++++++--- 4 files changed, 29 insertions(+), 11 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/db') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt index b81ce365..303ab70a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt @@ -83,7 +83,10 @@ object CookiesDb { @Parcelize @Table(database = CookiesDb::class, allFields = true, primaryKeyConflict = ConflictAction.REPLACE) -data class CookieModel(@PrimaryKey var id: Long = -1L, var name: String? = null, var cookie: String? = null) : +data class CookieModel( + @PrimaryKey var id: Long = -1L, var name: String? = null, + var cookie: String? = null +) : BaseModel(), Parcelable { override fun toString(): String = "CookieModel(${hashCode()})" diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt index cd5fce02..5519f6a8 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt @@ -59,7 +59,10 @@ interface FrostDao : FrostPrivateDao, FrostPublicDao { /** * Composition of all database interfaces */ -class FrostDatabase(private val privateDb: FrostPrivateDatabase, private val publicDb: FrostPublicDatabase) : +class FrostDatabase( + private val privateDb: FrostPrivateDatabase, + private val publicDb: FrostPublicDatabase +) : FrostDao, FrostPrivateDao by privateDb, FrostPublicDao by publicDb { @@ -71,11 +74,12 @@ class FrostDatabase(private val privateDb: FrostPrivateDatabase, private val pub companion object { - private fun RoomDatabase.Builder.frostBuild() = if (BuildConfig.DEBUG) { - fallbackToDestructiveMigration().build() - } else { - build() - } + private fun RoomDatabase.Builder.frostBuild() = + if (BuildConfig.DEBUG) { + fallbackToDestructiveMigration().build() + } else { + build() + } fun create(context: Context): FrostDatabase { val privateDb = Room.databaseBuilder( diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt index a704ce82..475d134f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt @@ -35,4 +35,5 @@ object FbTabsDb { } @Table(database = FbTabsDb::class, allFields = true) -data class FbTabModel(@PrimaryKey var position: Int = -1, var tab: FbItem = FbItem.FEED) : BaseModel() +data class FbTabModel(@PrimaryKey var position: Int = -1, var tab: FbItem = FbItem.FEED) : + BaseModel() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/NotificationDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/NotificationDb.kt index 813c39a3..e89bf46d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/db/NotificationDb.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/db/NotificationDb.kt @@ -140,14 +140,20 @@ suspend fun NotificationDao.deleteAll() = dao { _deleteAll() } fun NotificationDao.selectNotificationsSync(userId: Long, type: String): List = _selectNotifications(userId, type).map { it.toNotifContent() } -suspend fun NotificationDao.selectNotifications(userId: Long, type: String): List = dao { +suspend fun NotificationDao.selectNotifications( + userId: Long, + type: String +): List = dao { selectNotificationsSync(userId, type) } /** * Returns true if successful, given that there are constraints to the insertion */ -suspend fun NotificationDao.saveNotifications(type: String, notifs: List): Boolean = dao { +suspend fun NotificationDao.saveNotifications( + type: String, + notifs: List +): Boolean = dao { try { _saveNotifications(type, notifs) true @@ -187,7 +193,11 @@ class NotificationMigration2(modelClass: Class) : } } -@Table(database = NotificationDb::class, allFields = true, primaryKeyConflict = ConflictAction.REPLACE) +@Table( + database = NotificationDb::class, + allFields = true, + primaryKeyConflict = ConflictAction.REPLACE +) data class NotificationModel( @PrimaryKey var id: Long = -1L, var epoch: Long = -1L, -- cgit v1.2.3