I want to preview photos in compressed files without decompressing the files
Currently, for zip files, I use ZipFile and ZipEntry to view them, but they only work with zip files.
So I continue to use another library 7-Zip-JBinding enter link description here
I got some data, but I don’t know how to display the image. Here is the code that uses that library
private suspend fun checkFileZip(filePath: String): MutableList<PhotoModel> {
return withContext(Dispatchers.IO) {
val list: MutableList<PhotoModel> = mutableListOf()
runCatching {
val randomAccessFile = RandomAccessFile(filePath, "r")
val randomAccessFileStream = RandomAccessFileInStream(randomAccessFile)
val inArchive = SevenZip.openInArchive(null, randomAccessFileStream)
inArchive.simpleInterface.archiveItems?.forEach { item ->
if (!item.isFolder) {
if (item.path.contains(".jpg") || item.path.contains(".png")) {
if (item.size > 10000) {
val photoModel = PhotoModel(
"$filePath/${item.path.toFolderName()}",
resolution = "",
sizePhoto = item.size,
lastModifiedPhoto = item.lastWriteTime.time,
isFileInApk = true,
zipFileString = filePath,
zipEntryString = filePath
)
addPhotoModel(photoModel)
list.add(photoModel)
}
}
}
}
}.onFailure {
Log.d("error", "$filePath - ${it.message}")
}
return@withContext list
}
}
I want to know how to preview image files contained in compressed files. Hope the helping