mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-08 00:39:54 +00:00
Update: Merge Installed(Item)'s entity and database.entity classes
This commit is contained in:
parent
e2791f3c38
commit
d5c1fb9fb6
@ -280,14 +280,8 @@ interface CategoryDao : BaseDao<Category> {
|
||||
// TODO make sure that apps that not uninstalled by Droid-ify still get removed
|
||||
@Dao
|
||||
interface InstalledDao : BaseDao<Installed> {
|
||||
fun put(vararg isntalled: com.looker.droidify.entity.InstalledItem) {
|
||||
isntalled.forEach {
|
||||
insertReplace(Installed(it.packageName).apply {
|
||||
version = it.version
|
||||
version_code = it.versionCode
|
||||
signature = it.signature
|
||||
})
|
||||
}
|
||||
fun put(vararg installed: Installed) {
|
||||
installed.forEach { insertReplace(it) }
|
||||
}
|
||||
|
||||
@Query("SELECT * FROM memory_installed WHERE package_name = :packageName")
|
||||
@ -296,6 +290,9 @@ interface InstalledDao : BaseDao<Installed> {
|
||||
@Query("SELECT * FROM memory_installed WHERE package_name = :packageName")
|
||||
fun getObject(packageName: String): Installed?
|
||||
|
||||
@Query("SELECT * FROM memory_installed WHERE package_name = :packageName")
|
||||
fun getObjectLive(packageName: String): LiveData<Installed?>
|
||||
|
||||
@Query("DELETE FROM memory_installed WHERE package_name = :packageName")
|
||||
fun delete(packageName: String)
|
||||
}
|
||||
|
@ -4,11 +4,10 @@ import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "memory_installed")
|
||||
class Installed(pName: String = "") {
|
||||
data class Installed(
|
||||
@PrimaryKey
|
||||
var package_name = pName
|
||||
|
||||
var version = ""
|
||||
var version_code = 0L
|
||||
var signature = ""
|
||||
}
|
||||
var package_name: String = "",
|
||||
var version: String = "",
|
||||
var version_code: Long = 0L,
|
||||
var signature: String = ""
|
||||
)
|
@ -1,9 +0,0 @@
|
||||
package com.looker.droidify.entity
|
||||
|
||||
// Redundant to Room's Installed
|
||||
class InstalledItem(
|
||||
val packageName: String,
|
||||
val version: String,
|
||||
val versionCode: Long,
|
||||
val signature: String,
|
||||
)
|
@ -18,7 +18,6 @@ import com.looker.droidify.*
|
||||
import com.looker.droidify.content.Preferences
|
||||
import com.looker.droidify.database.entity.Installed
|
||||
import com.looker.droidify.database.entity.Repository
|
||||
import com.looker.droidify.entity.InstalledItem
|
||||
import com.looker.droidify.entity.Product
|
||||
import com.looker.droidify.entity.ProductItem
|
||||
import com.looker.droidify.service.Connection
|
||||
@ -46,9 +45,9 @@ object Utils {
|
||||
.apply { setTintList(context.getColorFromAttr(tintAttrResId)) }
|
||||
}
|
||||
|
||||
fun PackageInfo.toInstalledItem(): InstalledItem {
|
||||
fun PackageInfo.toInstalledItem(): Installed {
|
||||
val signatureString = singleSignature?.let(Utils::calculateHash).orEmpty()
|
||||
return InstalledItem(packageName, versionName.orEmpty(), versionCodeCompat, signatureString)
|
||||
return Installed(packageName, versionName.orEmpty(), versionCodeCompat, signatureString)
|
||||
}
|
||||
|
||||
fun getDefaultApplicationIcons(context: Context): Pair<Drawable, Drawable> {
|
||||
@ -221,13 +220,6 @@ fun Cursor.getRepository(): Repository = getBlob(getColumnIndex(ROW_DATA))
|
||||
}
|
||||
}
|
||||
|
||||
fun Cursor.getInstalledItem(): InstalledItem = InstalledItem(
|
||||
getString(getColumnIndex(ROW_PACKAGE_NAME)),
|
||||
getString(getColumnIndex(ROW_VERSION)),
|
||||
getLong(getColumnIndex(ROW_VERSION_CODE)),
|
||||
getString(getColumnIndex(ROW_SIGNATURE))
|
||||
)
|
||||
|
||||
fun <T> ByteArray.jsonParse(callback: (JsonParser) -> T): T {
|
||||
return Json.factory.createParser(this).use { it.parseDictionary(callback) }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user