Skip to content

Commit

Permalink
Adapting to changes in arklib [work in progress]
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillt committed Jan 14, 2023
1 parent 3a87a78 commit ac7f49b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ android {
}

dependencies {
implementation 'space.taran:arklib:0.1.0-SNAPSHOT-560bfc5d8d'
implementation 'space.taran:arklib:0.1.0-SNAPSHOT-3334850384'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package space.taran.arknavigator.mvp.model.repo.index

import java.nio.file.Path

typealias ResourceId = Long

// Reading from SD card is up to 3 times slower!
// Calculating CRC-32 hash of a file takes about the
// same time as reading the file from internal storage.

private external fun computeIdNative(size: Long, file: String): Long
// private external fun computeIdNative(size: Long, file: String): Long

fun computeId(size: Long, file: Path): ResourceId {
return computeIdNative(size, file.toString())
}
// fun computeId(size: Long, file: Path): ResourceId {
// return computeIdNative(size, file.toString())
// }
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package space.taran.arknavigator.mvp.model.repo.index

import space.taran.arklib.computeId
import space.taran.arknavigator.mvp.model.dao.ResourceWithExtra
import space.taran.arknavigator.mvp.model.repo.kind.GeneralKindFactory
import space.taran.arknavigator.mvp.model.repo.kind.ResourceKind
Expand All @@ -12,7 +13,7 @@ import java.nio.file.Path
import java.nio.file.attribute.FileTime

data class ResourceMeta(
val id: ResourceId,
val id: Long, // TODO: must be ResourceId
val name: String,
val extension: String,
val modified: FileTime,
Expand All @@ -27,7 +28,8 @@ data class ResourceMeta(
return MetaResult.failure(IOException("Invalid file size"))
}

val id = computeId(size, path)
// TODO: must be full id after migration
val id = computeId(size, path).crc32

val meta = ResourceMeta(
id = id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package space.taran.arknavigator.mvp.model.repo.preview.generator

import android.graphics.Bitmap
import android.graphics.BitmapFactory
import space.taran.arklib.loadLinkPreview
import java.nio.file.Path
import kotlin.io.path.pathString

object LinkPreviewGenerator : PreviewGenerator() {
override val acceptedExtensions = setOf("link")
Expand All @@ -18,11 +15,12 @@ object LinkPreviewGenerator : PreviewGenerator() {
}

private fun generatePreview(source: Path): Bitmap {
val previewBytes =
loadLinkPreview(source.pathString) ?: error("No image inside .link file")
if (previewBytes.isEmpty()) {
error("Image inside .link file was empty")
}
return BitmapFactory.decodeByteArray(previewBytes, 0, previewBytes.size)
throw NotImplementedError()
// val previewBytes =
// loadLinkPreview(source.pathString) ?: error("No image inside .link file")
// if (previewBytes.isEmpty()) {
// error("Image inside .link file was empty")
// }
// return BitmapFactory.decodeByteArray(previewBytes, 0, previewBytes.size)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ object PdfPreviewGenerator : PreviewGenerator() {
}

private fun generatePreview(source: Path): Bitmap {
// TODO: quality must be configurable in preferences screen
return pdfPreviewGenerate(source.toString(), PreviewQuality.HIGH)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MainActivity : MvpAppCompatActivity(), MainView {
System.loadLibrary("arklib")
initRustLogger()

setSupportActionBar(binding.toolbar)
// setSupportActionBar(binding.toolbar)
binding.bottomNavigation.setOnApplyWindowInsetsListener(null)
binding.bottomNavigation.setOnItemSelectedListener { item ->
when (item.itemId) {
Expand Down

0 comments on commit ac7f49b

Please sign in to comment.