Initial commit

This commit is contained in:
tanexc
2026-06-12 23:49:11 +03:00
commit f69ffd79c2
222 changed files with 7094 additions and 0 deletions
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
@@ -0,0 +1,33 @@
package ru.tanexc.hemoanalysis.usecase
import android.content.Context
import android.util.Log
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import ru.tanexc.hemoanalysis.Constants.INTERNAL_MODELS_DIR
import ru.tanexc.hemoanalysis.domain.repository.ModelRepository
import ru.tanexc.hemoanalysis.domain.usecase.GetLatestModelFileUseCase
import java.io.File
internal actual class GetLatestModelFileUseCaseImpl : GetLatestModelFileUseCase, KoinComponent {
private val context: Context by inject()
private val modelRepository: ModelRepository by inject()
actual override operator fun invoke(): ByteArray? {
val filename = modelRepository.getCurrentModelInfo()?.filename?: return null
val modelsDir = File(context.filesDir, INTERNAL_MODELS_DIR)
if (!modelsDir.exists()) return null
val modelFile = File(modelsDir, filename)
if (!modelFile.exists()) return null
Log.i("GetLatestModelFileUseCase", "get model bytearray ${modelFile.absolutePath}")
return modelFile.inputStream().buffered().use { inputStream ->
inputStream.readBytes()
}
}
}
@@ -0,0 +1,15 @@
package ru.tanexc.hemoanalysis.usecase
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import ru.tanexc.hemoanalysis.domain.repository.ModelRepository
import ru.tanexc.hemoanalysis.domain.usecase.GetModelPathUseCase
import kotlin.getValue
actual class GetModelPathUseCaseImpl actual constructor() : GetModelPathUseCase, KoinComponent {
private val modelRepository: ModelRepository by inject()
actual override fun invoke(): String? {
return modelRepository.getCurrentModelInfo()?.filename
}
}
@@ -0,0 +1,42 @@
package ru.tanexc.hemoanalysis.usecase
import android.content.Context
import android.util.Log
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import ru.tanexc.hemoanalysis.Constants.INTERNAL_MODELS_DIR
import ru.tanexc.hemoanalysis.domain.model.Size
import ru.tanexc.hemoanalysis.domain.usecase.BytesReader
import ru.tanexc.hemoanalysis.domain.usecase.SaveModelFileUseCase
import java.io.File
internal actual class SaveModelFileUseCaseImpl : SaveModelFileUseCase, KoinComponent {
val context: Context by inject()
actual override suspend operator fun invoke(
filename: String,
bytesReader: BytesReader
): Size {
val modelsDir = File(context.filesDir, INTERNAL_MODELS_DIR)
modelsDir.mkdirs()
Log.i("SaveModelFileUseCase", "saving model into ${modelsDir.absolutePath}")
val modelFile = File(modelsDir, filename)
modelFile.outputStream().buffered().use { output ->
var bytes = bytesReader.readNext(BUFFER_SIZE)
while (bytes.isNotEmpty()) {
output.write(bytes)
bytes = bytesReader.readNext(BUFFER_SIZE)
}
}
Log.i("SaveModelFileUseCase", "model saved into file $modelFile ${modelFile.length()}")
return Size(modelFile.length().toInt())
}
private val BUFFER_SIZE = 1024 * 1024
}