Fix animated image detection (#5826)
This commit is contained in:
parent
ab036312a4
commit
bd033db84c
@ -264,17 +264,17 @@ class PagerPageHolder(
|
|||||||
.fromCallable {
|
.fromCallable {
|
||||||
val stream = streamFn().buffered(16)
|
val stream = streamFn().buffered(16)
|
||||||
val itemStream = process(item, stream)
|
val itemStream = process(item, stream)
|
||||||
|
val bais = ByteArrayInputStream(itemStream.readBytes())
|
||||||
try {
|
try {
|
||||||
val streamBytes = itemStream.readBytes()
|
val isAnimated = ImageUtil.isAnimatedAndSupported(bais)
|
||||||
val isAnimated = ImageUtil.isAnimatedAndSupported(stream)
|
bais.reset()
|
||||||
val background = if (!isAnimated && viewer.config.automaticBackground) {
|
val background = if (!isAnimated && viewer.config.automaticBackground) {
|
||||||
ByteArrayInputStream(streamBytes).use { bais ->
|
|
||||||
ImageUtil.chooseBackground(context, bais)
|
ImageUtil.chooseBackground(context, bais)
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
Triple(streamBytes, isAnimated, background)
|
bais.reset()
|
||||||
|
Triple(bais, isAnimated, background)
|
||||||
} finally {
|
} finally {
|
||||||
stream.close()
|
stream.close()
|
||||||
itemStream.close()
|
itemStream.close()
|
||||||
@ -282,15 +282,15 @@ class PagerPageHolder(
|
|||||||
}
|
}
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.doOnNext { (streamBytes, isAnimated, background) ->
|
.doOnNext { (bais, isAnimated, background) ->
|
||||||
ByteArrayInputStream(streamBytes).use { bais ->
|
bais.use {
|
||||||
if (!isAnimated) {
|
if (!isAnimated) {
|
||||||
this.background = background
|
this.background = background
|
||||||
initSubsamplingImageView().apply {
|
initSubsamplingImageView().apply {
|
||||||
setImage(ImageSource.inputStream(bais))
|
setImage(ImageSource.inputStream(it))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
initImageView().setImage(bais)
|
initImageView().setImage(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user