mirror of
https://github.com/gedoor/legado.git
synced 2024-07-19 01:17:25 +08:00
优化
This commit is contained in:
parent
26156331a4
commit
30a181bf27
@ -49,9 +49,9 @@ object DirectLinkUpload {
|
|||||||
zipFile
|
zipFile
|
||||||
}
|
}
|
||||||
|
|
||||||
is ByteArray -> ZipUtils.zipByteArray(file)
|
is ByteArray -> ZipUtils.zipByteArray(file, fileName)
|
||||||
is String -> ZipUtils.zipString(file)
|
is String -> ZipUtils.zipByteArray(file.toByteArray(), fileName)
|
||||||
else -> ZipUtils.zipString(GSON.toJson(file))
|
else -> ZipUtils.zipByteArray(GSON.toJson(file).toByteArray(), fileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val analyzeUrl = AnalyzeUrl(url)
|
val analyzeUrl = AnalyzeUrl(url)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
@file:Suppress("unused")
|
||||||
|
|
||||||
package io.legado.app.lib.dialogs
|
package io.legado.app.lib.dialogs
|
||||||
|
|
||||||
|
@ -16,19 +16,28 @@ import java.util.zip.*
|
|||||||
@Suppress("unused", "MemberVisibilityCanBePrivate")
|
@Suppress("unused", "MemberVisibilityCanBePrivate")
|
||||||
object ZipUtils {
|
object ZipUtils {
|
||||||
|
|
||||||
fun zipByteArray(byteArray: ByteArray): ByteArray {
|
fun gzipByteArray(byteArray: ByteArray): ByteArray {
|
||||||
val byteOut = ByteArrayOutputStream()
|
val byteOut = ByteArrayOutputStream()
|
||||||
val zip = GZIPOutputStream(byteOut)
|
val zip = GZIPOutputStream(byteOut)
|
||||||
zip.use {
|
return zip.use {
|
||||||
it.write(byteArray)
|
it.write(byteArray)
|
||||||
}
|
byteOut.use {
|
||||||
return byteOut.use {
|
byteOut.toByteArray()
|
||||||
it.toByteArray()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun zipString(text: String): ByteArray {
|
fun zipByteArray(byteArray: ByteArray, fileName: String): ByteArray {
|
||||||
return zipByteArray(text.toByteArray())
|
val byteOut = ByteArrayOutputStream()
|
||||||
|
val zipOutputStream = ZipOutputStream(byteOut)
|
||||||
|
zipOutputStream.putNextEntry(ZipEntry(fileName))
|
||||||
|
zipOutputStream.write(byteArray)
|
||||||
|
zipOutputStream.closeEntry()
|
||||||
|
return zipOutputStream.use {
|
||||||
|
byteOut.use {
|
||||||
|
byteOut.toByteArray()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user