iielse / imageviewer

A simple and customizable Android full-screen image viewer 一个简单且可自定义的Android全屏图像浏览器

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ItemType.SUBSAMPLING加载方式自定义退出动画异常

victorfan336 opened this issue · comments

用了2.1.1.版本的代码,自定义居中退出动画:
class CustomTransformer(val context: Context) : Transformer {

override fun getView(key: Long): ImageView? {
    return fakeStartView()
}

private fun fakeStartView()=  ImageView(context).apply {
    setTag(R.id.viewer_start_view_location_0, DisplayUtil.screenWidth / 2)
    setTag(R.id.viewer_start_view_location_1, DisplayUtil.screenHeight / 2)
}

}
动画效果在设置为ItemType.PHOTO加载时,动画效果正常。
当设置为ItemType.SUBSAMPLING加载时,退出动画就有点飘忽了。不像ItemType.PHOTO那样从中间退出。

为避免是我自己代码导致的问题,我特意修改了下demo,在repository.kt的myData后,加了三天数据,数据是从image中拷贝过来的,然后设置type=ItemType.SUBSAMPLING,运行发现,动画效果跟我上面自定义后的效果是一样的,也就是如果不是超大长图,用了ItemType.SUBSAMPLING方式的话,会导致退出时的过渡效果异常。
val myData: List by lazy {
mutableListOf(
// long horizontal
MyData(subsampling = true, id = id++, url = "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Along_the_River_During_the_Qingming_Festival_%28Qing_Court_Version%29.jpg/1920px-Along_the_River_During_the_Qingming_Festival_%28Qing_Court_Version%29.jpg"),
// long vertical
MyData(subsampling = true, id = id++, url = "https://image.shutterstock.com/z/stock-vector-humerus-of-the-right-side-from-its-front-face-vintage-engraved-illustration-usual-medicine-90201004.jpg"),
// video
MyData(id = id++, url = "https://media.w3.org/2010/05/sintel/trailer.mp4"),
MyData(id = id++, url = "https://www.w3schools.com/html/movie.mp4"),
MyData(id = id++, url = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"),
MyData(subsampling = true, id = id++, url = "https://images.unsplash.com/photo-1550684863-a70a48d476d5?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60"),
MyData(subsampling = true, id = id++, url = "https://images.unsplash.com/photo-1496963729609-7d408fa580b5?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60"),
MyData(subsampling = true, id = id++, url = "https://images.unsplash.com/photo-1531959870249-9f9b729efcf4?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60")
).let {
it.apply { addAll(image.map { MyData(id = id++, url = it) }) }
}.toList()
}
其他代码不改。
可以看视频效果:
链接:https://pan.baidu.com/s/1DTY4HmfzqsZrVcXzl45CYg 密码:v438

其实,我只是想所有图片都是用SUBSAMPLING来加载,因为判断url是不是长图很方便,因为photoview显示超大图效果不好,但是SUBSAMPLING又不能显示网络图,哭晕在厕所.jpg,不如直接全部用SUBSAMPLING算了,就发现了上面说的问题。请问下大佬有什么比较优雅的处理方式吗?

麻烦大佬看看。

commented

区块加载超大图没支持transition动画.这个bug我这边打算是保留
subsampling-scale-image-view issues 313
等巨佬们来解决这个问题. 目前viewer选择使用淡出动画

关于图片的类型模式是否是大图.
一个图到底是不是长图断定标准viewer这边定不了.还是需要开发者来确认
图片如果是你上传到自己业务服务器上的. 宽高尺寸你是知道的呀.
托管在云上的图片,一般也有imageInfo之类的接口可以拿到尺寸.