This commit is contained in:
ag2s20150909
2023-09-24 18:19:42 +08:00
committed by GitHub
parent be0faf93da
commit 6c25de8e75
16 changed files with 47 additions and 65 deletions
@@ -50,7 +50,7 @@ class RssArticlesAdapter(context: Context, callBack: CallBack) :
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
imageView.gone()
@@ -58,10 +58,10 @@ class RssArticlesAdapter(context: Context, callBack: CallBack) :
}
override fun onResourceReady(
resource: Drawable?,
model: Any?,
resource: Drawable,
model: Any,
target: Target<Drawable>?,
dataSource: DataSource?,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
imageView.visible()
@@ -50,7 +50,7 @@ class RssArticlesAdapter1(context: Context, callBack: CallBack) :
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
imageView.gone()
@@ -58,10 +58,10 @@ class RssArticlesAdapter1(context: Context, callBack: CallBack) :
}
override fun onResourceReady(
resource: Drawable?,
model: Any?,
resource: Drawable,
model: Any,
target: Target<Drawable>?,
dataSource: DataSource?,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
imageView.visible()
@@ -50,7 +50,7 @@ class RssArticlesAdapter2(context: Context, callBack: CallBack) :
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
imageView.gone()
@@ -58,10 +58,10 @@ class RssArticlesAdapter2(context: Context, callBack: CallBack) :
}
override fun onResourceReady(
resource: Drawable?,
model: Any?,
resource: Drawable,
model: Any,
target: Target<Drawable>?,
dataSource: DataSource?,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
imageView.visible()
@@ -45,7 +45,7 @@ class RssFavoritesAdapter(context: Context, val callBack: CallBack) :
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
imageView.gone()
@@ -53,10 +53,10 @@ class RssFavoritesAdapter(context: Context, val callBack: CallBack) :
}
override fun onResourceReady(
resource: Drawable?,
model: Any?,
resource: Drawable,
model: Any,
target: Target<Drawable>?,
dataSource: DataSource?,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
imageView.visible()
@@ -1,7 +1,11 @@
package io.legado.app.ui.widget.image
import android.content.Context
import android.graphics.*
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.Path
import android.graphics.Typeface
import android.graphics.drawable.Drawable
import android.text.TextPaint
import android.util.AttributeSet
@@ -150,7 +154,7 @@ class CoverImageView @JvmOverloads constructor(
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
defaultCover = true
@@ -158,10 +162,10 @@ class CoverImageView @JvmOverloads constructor(
}
override fun onResourceReady(
resource: Drawable?,
model: Any?,
resource: Drawable,
model: Any,
target: Target<Drawable>?,
dataSource: DataSource?,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
defaultCover = false
@@ -4,7 +4,6 @@ import android.os.ParcelFileDescriptor
import android.system.ErrnoException
import android.system.Os
import android.system.OsConstants
import android.system.OsConstants.S_IFDIR
import android.system.OsConstants.S_ISDIR
import io.legado.app.lib.icu4j.CharsetDetector
import me.zhanghai.android.libarchive.Archive
@@ -231,8 +230,9 @@ object LibArchiveUtils {
try {
var entry = Archive.readNextHeader(archive)
while (entry != 0L) {
var entry: Long
while (Archive.readNextHeader(archive).also { entry = it } != 0L) {
val entryName =
getEntryString(ArchiveEntry.pathnameUtf8(entry), ArchiveEntry.pathname(entry))
?: continue
@@ -243,11 +243,10 @@ object LibArchiveUtils {
val entryStat = ArchiveEntry.stat(entry)
//判断是否是文件夹
if (S_ISDIR(entryStat.stMode)) {
if (entryStat.isDir()) {
if (!entryFile.exists()) {
entryFile.mkdirs()
}
entry = Archive.readNextHeader(archive)
continue
}
@@ -268,8 +267,6 @@ object LibArchiveUtils {
files.add(entryFile)
}
entry = Archive.readNextHeader(archive)
}
} finally {
@@ -287,8 +284,8 @@ object LibArchiveUtils {
fun getByteArrayContent(inputStream: InputStream, path: String): ByteArray? {
val archive = openArchive(inputStream)
try {
var entry = Archive.readNextHeader(archive)
while (entry != 0L) {
var entry: Long
while (Archive.readNextHeader(archive).also { entry = it } != 0L) {
val entryName =
getEntryString(ArchiveEntry.pathnameUtf8(entry), ArchiveEntry.pathname(entry))
?: continue
@@ -296,8 +293,7 @@ object LibArchiveUtils {
val entryStat = ArchiveEntry.stat(entry)
//判断是否是文件夹
if (S_ISDIR(entryStat.stMode)) {
entry = Archive.readNextHeader(archive)
if (entryStat.isDir()) {
continue
}
@@ -315,7 +311,6 @@ object LibArchiveUtils {
}
}
entry = Archive.readNextHeader(archive)
}
} finally {
@@ -331,22 +326,19 @@ object LibArchiveUtils {
): List<String> {
val fileNames = mutableListOf<String>()
try {
//Archive.readOpenFd(archive, pfd.fd, 8192)
var entry = Archive.readNextHeader(archive)
//val formatName: String = newStringFromBytes(Archive.formatName(archive))
while (entry != 0L) {
var entry: Long
while (Archive.readNextHeader(archive).also { entry = it } != 0L) {
val fileName =
getEntryString(ArchiveEntry.pathnameUtf8(entry), ArchiveEntry.pathname(entry))
?: continue
val entryStat = ArchiveEntry.stat(entry)
val fileType = entryStat.stMode and S_IFDIR
if (S_ISDIR(entryStat.stMode)) {
entry = Archive.readNextHeader(archive)
if (entryStat.isDir()) {
continue
}
@@ -363,6 +355,7 @@ object LibArchiveUtils {
return fileNames
}
private fun ArchiveEntry.StructStat.isDir() = S_ISDIR(this.stMode)
private fun getEntryString(utf8: String?, bytes: ByteArray?): String? {
return utf8 ?: newStringFromBytes(bytes)