aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt16
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/dbflow/DbUtils.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/dbflow/NotificationDb.kt2
-rw-r--r--gradle.properties2
6 files changed, 23 insertions, 9 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
index ad06f3a6..2c313ffe 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
@@ -14,6 +14,9 @@ import com.crashlytics.android.Crashlytics
import com.crashlytics.android.answers.Answers
import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader
import com.mikepenz.materialdrawer.util.DrawerImageLoader
+import com.pitchedapps.frost.dbflow.CookiesDb
+import com.pitchedapps.frost.dbflow.FbTabsDb
+import com.pitchedapps.frost.dbflow.NotificationDb
import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.services.scheduleNotifications
import com.pitchedapps.frost.services.setupNotificationChannels
@@ -21,10 +24,12 @@ import com.pitchedapps.frost.utils.FrostPglAdBlock
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.Showcase
+import com.raizlabs.android.dbflow.config.DatabaseConfig
import com.raizlabs.android.dbflow.config.FlowConfig
import com.raizlabs.android.dbflow.config.FlowManager
import io.fabric.sdk.android.Fabric
import java.util.*
+import kotlin.reflect.KClass
/**
@@ -38,8 +43,17 @@ class FrostApp : Application() {
// lateinit var refWatcher: RefWatcher
+ private fun FlowConfig.Builder.withDatabase(name: String, klass: KClass<*>) =
+ addDatabaseConfig(DatabaseConfig.builder(klass.java)
+ .databaseName(name)
+ .build())
+
override fun onCreate() {
- FlowManager.init(FlowConfig.Builder(this).build())
+ FlowManager.init(FlowConfig.Builder(this)
+ .withDatabase(CookiesDb.NAME, CookiesDb::class)
+ .withDatabase(FbTabsDb.NAME, FbTabsDb::class)
+ .withDatabase(NotificationDb.NAME, NotificationDb::class)
+ .build())
Showcase.initialize(this, "${BuildConfig.APPLICATION_ID}.showcase")
Prefs.initialize(this, "${BuildConfig.APPLICATION_ID}.prefs")
// if (LeakCanary.isInAnalyzerProcess(this)) return
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt
index 8c5806c8..ff46856c 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt
@@ -21,7 +21,7 @@ import java.net.UnknownHostException
* Created by Allan Wang on 2017-05-30.
*/
-@Database(name = CookiesDb.NAME, version = CookiesDb.VERSION)
+@Database(version = CookiesDb.VERSION)
object CookiesDb {
const val NAME = "Cookies"
const val VERSION = 2
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/DbUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/DbUtils.kt
index bb2627a5..f5c962ed 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/DbUtils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/DbUtils.kt
@@ -17,8 +17,8 @@ object DbUtils {
}
-inline fun <reified T : Any> List<T>.replace(context: Context, dbName: String) {
+inline fun <reified T : Any> List<T>.replace(dbName: String) {
L.d("Replacing $dbName.db")
- DbUtils.db(dbName).reset(context)
+ DbUtils.db(dbName).reset()
FastStoreModelTransaction.saveBuilder(FlowManager.getModelAdapter(T::class.java)).addAll(this).build()
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt
index 4b2d3403..c68c9420 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt
@@ -15,7 +15,7 @@ import com.raizlabs.android.dbflow.structure.BaseModel
* Created by Allan Wang on 2017-05-30.
*/
-@Database(name = FbTabsDb.NAME, version = FbTabsDb.VERSION)
+@Database( version = FbTabsDb.VERSION)
object FbTabsDb {
const val NAME = "FrostTabs"
const val VERSION = 1
@@ -31,6 +31,6 @@ fun loadFbTabs(): List<FbItem> {
return defaultTabs()
}
-fun List<FbItem>.saveAsync(c: Context) {
- mapIndexed { index, fbTab -> FbTabModel(index, fbTab) }.replace(c, FbTabsDb.NAME)
+fun List<FbItem>.saveAsync() {
+ mapIndexed { index, fbTab -> FbTabModel(index, fbTab) }.replace(FbTabsDb.NAME)
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/NotificationDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/NotificationDb.kt
index 66f5ae64..d3abb9a2 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/NotificationDb.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/NotificationDb.kt
@@ -11,7 +11,7 @@ import com.raizlabs.android.dbflow.structure.BaseModel
* Created by Allan Wang on 2017-05-30.
*/
-@Database(name = NotificationDb.NAME, version = NotificationDb.VERSION)
+@Database(version = NotificationDb.VERSION)
object NotificationDb {
const val NAME = "Notifications"
const val VERSION = 2
diff --git a/gradle.properties b/gradle.properties
index e1d1a99f..33d0afd6 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -22,7 +22,7 @@ KOTLIN=1.1.51
COMMONS_TEXT=1.1
CRASHLYTICS=2.7.1
-DBFLOW=4.0.5
+DBFLOW=4.1.2
EXOMEDIA=4.0.3
IAB=1.0.44
IICON_COMMUNITY=1.9.32.2