data: [WIP] prepare for ModelRepository refactor & impl
This commit is contained in:
parent
b6cc8f0c01
commit
f5e2edda87
|
|
@ -7,12 +7,17 @@ import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository for managing available models.
|
||||||
|
*/
|
||||||
interface ModelRepository {
|
interface ModelRepository {
|
||||||
|
// TODO-han.yin: change to Flow for getters
|
||||||
|
suspend fun getStorageMetrics(): StorageMetrics
|
||||||
suspend fun getModels(): List<ModelInfo>
|
suspend fun getModels(): List<ModelInfo>
|
||||||
|
|
||||||
|
suspend fun importModel(uri: Uri): ModelInfo
|
||||||
suspend fun deleteModel(modelId: String)
|
suspend fun deleteModel(modelId: String)
|
||||||
suspend fun deleteModels(modelIds: Collection<String>)
|
suspend fun deleteModels(modelIds: Collection<String>)
|
||||||
suspend fun importModel(uri: Uri): ModelInfo
|
|
||||||
suspend fun getStorageMetrics(): StorageMetrics
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|
@ -21,11 +26,21 @@ class ModelRepositoryImpl @Inject constructor(
|
||||||
// TODO-han.yin: Add model DAO
|
// TODO-han.yin: Add model DAO
|
||||||
) : ModelRepository {
|
) : ModelRepository {
|
||||||
|
|
||||||
|
override suspend fun getStorageMetrics(): StorageMetrics {
|
||||||
|
// Stub - would calculate from actual storage
|
||||||
|
return StorageMetrics(14.6f, 32.0f)
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun getModels(): List<ModelInfo> {
|
override suspend fun getModels(): List<ModelInfo> {
|
||||||
// In a real implementation, this would load from database
|
// In a real implementation, this would load from database
|
||||||
return ModelInfo.getSampleModels()
|
return ModelInfo.getSampleModels()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun importModel(uri: Uri): ModelInfo {
|
||||||
|
// Stub - would copy file and extract metadata
|
||||||
|
return ModelInfo.getSampleModels().first()
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun deleteModel(modelId: String) {
|
override suspend fun deleteModel(modelId: String) {
|
||||||
// Stub - would delete from filesystem and database
|
// Stub - would delete from filesystem and database
|
||||||
}
|
}
|
||||||
|
|
@ -33,19 +48,15 @@ class ModelRepositoryImpl @Inject constructor(
|
||||||
override suspend fun deleteModels(modelIds: Collection<String>) {
|
override suspend fun deleteModels(modelIds: Collection<String>) {
|
||||||
// Stub - would delete from filesystem and database
|
// Stub - would delete from filesystem and database
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun importModel(uri: Uri): ModelInfo {
|
|
||||||
// Stub - would copy file and extract metadata
|
|
||||||
return ModelInfo.getSampleModels().first()
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun getStorageMetrics(): StorageMetrics {
|
|
||||||
// Stub - would calculate from actual storage
|
|
||||||
return StorageMetrics(14.6f, 32.0f)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data class StorageMetrics(
|
data class StorageMetrics(
|
||||||
val usedGB: Float,
|
val usedGB: Float,
|
||||||
val totalGB: Float
|
val totalGB: Float
|
||||||
)
|
) {
|
||||||
|
val percentUsed: Float
|
||||||
|
get() = if (totalGB > 0) usedGB / totalGB else 0f
|
||||||
|
|
||||||
|
val freeGB: Float
|
||||||
|
get() = totalGB - usedGB
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue