data: [WIP] prepare for ModelRepository refactor & impl

This commit is contained in:
Han Yin 2025-04-14 13:26:02 -07:00
parent b6cc8f0c01
commit f5e2edda87
1 changed files with 24 additions and 13 deletions

View File

@ -7,12 +7,17 @@ import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import javax.inject.Singleton
/**
* Repository for managing available models.
*/
interface ModelRepository {
// TODO-han.yin: change to Flow for getters
suspend fun getStorageMetrics(): StorageMetrics
suspend fun getModels(): List<ModelInfo>
suspend fun importModel(uri: Uri): ModelInfo
suspend fun deleteModel(modelId: String)
suspend fun deleteModels(modelIds: Collection<String>)
suspend fun importModel(uri: Uri): ModelInfo
suspend fun getStorageMetrics(): StorageMetrics
}
@Singleton
@ -21,11 +26,21 @@ class ModelRepositoryImpl @Inject constructor(
// TODO-han.yin: Add model DAO
) : ModelRepository {
override suspend fun getStorageMetrics(): StorageMetrics {
// Stub - would calculate from actual storage
return StorageMetrics(14.6f, 32.0f)
}
override suspend fun getModels(): List<ModelInfo> {
// In a real implementation, this would load from database
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) {
// Stub - would delete from filesystem and database
}
@ -33,19 +48,15 @@ class ModelRepositoryImpl @Inject constructor(
override suspend fun deleteModels(modelIds: Collection<String>) {
// 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(
val usedGB: Float,
val totalGB: Float
)
) {
val percentUsed: Float
get() = if (totalGB > 0) usedGB / totalGB else 0f
val freeGB: Float
get() = totalGB - usedGB
}