mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-08 16:59:55 +00:00
Update: Migrate transformers (4.3/5 in replacing SQLite with Room)
This commit is contained in:
parent
78bb72c8e1
commit
a59bd2bd8a
@ -477,7 +477,7 @@ object Database {
|
|||||||
).observable(Subject.Repositories)
|
).observable(Subject.Repositories)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unnecessary with Room
|
// Done
|
||||||
fun transform(cursor: Cursor): Repository {
|
fun transform(cursor: Cursor): Repository {
|
||||||
return cursor.getBlob(cursor.getColumnIndex(Schema.Repository.ROW_DATA))
|
return cursor.getBlob(cursor.getColumnIndex(Schema.Repository.ROW_DATA))
|
||||||
.jsonParse {
|
.jsonParse {
|
||||||
@ -600,7 +600,7 @@ object Database {
|
|||||||
return builder.query(db, signal).observable(Subject.Products)
|
return builder.query(db, signal).observable(Subject.Products)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unnecessary with Room
|
// Done
|
||||||
private fun transform(cursor: Cursor): Product {
|
private fun transform(cursor: Cursor): Product {
|
||||||
return cursor.getBlob(cursor.getColumnIndex(Schema.Product.ROW_DATA))
|
return cursor.getBlob(cursor.getColumnIndex(Schema.Product.ROW_DATA))
|
||||||
.jsonParse {
|
.jsonParse {
|
||||||
@ -613,7 +613,7 @@ object Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO should be taken care of with extra functions that build on Room's queries
|
// Done
|
||||||
fun transformItem(cursor: Cursor): ProductItem {
|
fun transformItem(cursor: Cursor): ProductItem {
|
||||||
return cursor.getBlob(cursor.getColumnIndex(Schema.Product.ROW_DATA_ITEM))
|
return cursor.getBlob(cursor.getColumnIndex(Schema.Product.ROW_DATA_ITEM))
|
||||||
.jsonParse {
|
.jsonParse {
|
||||||
@ -726,7 +726,7 @@ object Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done with some changes in DAOS
|
// Done with some changes in DAOs
|
||||||
object LockAdapter {
|
object LockAdapter {
|
||||||
// Done in insert (Lock object instead of pair)
|
// Done in insert (Lock object instead of pair)
|
||||||
private fun put(lock: Pair<String, Long>, notify: Boolean) {
|
private fun put(lock: Pair<String, Long>, notify: Boolean) {
|
||||||
@ -766,6 +766,7 @@ object Database {
|
|||||||
private val Table.temporaryName: String
|
private val Table.temporaryName: String
|
||||||
get() = "${name}_temporary"
|
get() = "${name}_temporary"
|
||||||
|
|
||||||
|
// Done
|
||||||
fun createTemporaryTable() {
|
fun createTemporaryTable() {
|
||||||
db.execSQL("DROP TABLE IF EXISTS ${Schema.Product.temporaryName}")
|
db.execSQL("DROP TABLE IF EXISTS ${Schema.Product.temporaryName}")
|
||||||
db.execSQL("DROP TABLE IF EXISTS ${Schema.Category.temporaryName}")
|
db.execSQL("DROP TABLE IF EXISTS ${Schema.Category.temporaryName}")
|
||||||
|
@ -3,11 +3,14 @@ package com.looker.droidify.utility
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.PackageInfo
|
import android.content.pm.PackageInfo
|
||||||
import android.content.pm.Signature
|
import android.content.pm.Signature
|
||||||
|
import android.database.Cursor
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import com.looker.droidify.R
|
import com.looker.droidify.*
|
||||||
import com.looker.droidify.content.Preferences
|
import com.looker.droidify.content.Preferences
|
||||||
|
import com.looker.droidify.database.Database.jsonParse
|
||||||
import com.looker.droidify.entity.InstalledItem
|
import com.looker.droidify.entity.InstalledItem
|
||||||
import com.looker.droidify.entity.Product
|
import com.looker.droidify.entity.Product
|
||||||
|
import com.looker.droidify.entity.ProductItem
|
||||||
import com.looker.droidify.entity.Repository
|
import com.looker.droidify.entity.Repository
|
||||||
import com.looker.droidify.service.Connection
|
import com.looker.droidify.service.Connection
|
||||||
import com.looker.droidify.service.DownloadService
|
import com.looker.droidify.service.DownloadService
|
||||||
@ -109,3 +112,34 @@ object Utils {
|
|||||||
} else Unit
|
} else Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Cursor.getProduct(): Product = getBlob(getColumnIndex(ROW_DATA))
|
||||||
|
.jsonParse {
|
||||||
|
Product.deserialize(it).apply {
|
||||||
|
this.repositoryId = getLong(getColumnIndex(ROW_REPOSITORY_ID))
|
||||||
|
this.description = getString(getColumnIndex(ROW_DESCRIPTION))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun Cursor.getProductItem(): ProductItem = getBlob(getColumnIndex(ROW_DATA_ITEM))
|
||||||
|
.jsonParse {
|
||||||
|
ProductItem.deserialize(it).apply {
|
||||||
|
this.repositoryId = getLong(getColumnIndex(ROW_REPOSITORY_ID))
|
||||||
|
this.packageName = getString(getColumnIndex(ROW_PACKAGE_NAME))
|
||||||
|
this.name = getString(getColumnIndex(ROW_NAME))
|
||||||
|
this.summary = getString(getColumnIndex(ROW_SUMMARY))
|
||||||
|
this.installedVersion = getString(getColumnIndex(ROW_VERSION))
|
||||||
|
.orEmpty()
|
||||||
|
this.compatible = getInt(getColumnIndex(ROW_COMPATIBLE)) != 0
|
||||||
|
this.canUpdate = getInt(getColumnIndex(ROW_CAN_UPDATE)) != 0
|
||||||
|
this.matchRank = getInt(getColumnIndex(ROW_MATCH_RANK))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Cursor.getRepository(): Repository = getBlob(getColumnIndex(ROW_DATA))
|
||||||
|
.jsonParse {
|
||||||
|
Repository.deserialize(it).apply {
|
||||||
|
this.id = getLong(getColumnIndex(ROW_ID))
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user