iielse / imageviewer

A simple and customizable Android full-screen image viewer 一个简单且可自定义的Android全屏图像浏览器
MIT License
2.22k stars 310 forks source link

作者很强,但是案列相当不友好 #128

Closed DerrickChanJL closed 2 years ago

DerrickChanJL commented 2 years ago

不容易加入到已有项目中

DerrickChanJL commented 2 years ago

initKey 不生效

iielse commented 2 years ago

看下 demo 里面 TransitionViewsRef . 不过正在重构了

iielse commented 2 years ago

@DerrickChanJL demo 更新了

iielse commented 2 years ago

@DerrickChanJL readme 也更新了

DerrickChanJL commented 2 years ago

@DerrickChanJL readme 也更新了

感谢大佬

DerrickChanJL commented 2 years ago

@DerrickChanJL readme 也更新了

新案例一定要Android 12的 api31吗 哭

DerrickChanJL commented 2 years ago

@DerrickChanJL readme 也更新了

感谢大佬

引入跑不了,项目暂时不会适配31

DerrickChanJL commented 2 years ago

可以给个联系方式吗,initkey还是不生效

iielse commented 2 years ago

qq 517309507. 最近比较忙, 下个版本会把 targetSdkVersion 调到 30

iielse commented 2 years ago

你可以先下载源码, 自己打aar

iielse commented 2 years ago

@DerrickChanJL 2.1.11.

iielse commented 2 years ago

有新问题再打开

liamyu commented 2 years ago

initKey不生效可能是ImageViewerDialogFragment中的这段代码有问题

viewModel.dataList.observe(viewLifecycleOwner) { list ->
            adapter.submitList(list)
            initPosition = list.indexOfFirst { it.id == initKey }
            binding.viewer.setCurrentItem(initPosition, false)
        }
    /**
     * Set the new list to be displayed.
     *
     * If a list is already being displayed, a diff will be computed on a background thread, which
     * will dispatch Adapter.notifyItem events on the main thread.
     *
     * @param pagedList The new list to be displayed.
     */
    open fun submitList(@Suppress("DEPRECATION") pagedList: PagedList<T>?) =
        differ.submitList(pagedList)

这里说submitList有可能是异步的,因此submitList和setCurrentItem不能同步调用,断点也显示submitList以后去setCurrentItem时列表还是空的

有点晚了,改天再细看,先记录一下

iielse commented 2 years ago

你再看下 submitList 源码, 里面如果 mPagedList == null && mSnapshot == null . mPagedList 会同步赋值

liamyu commented 2 years ago

我依赖的paging版本是3.0.1,因为项目中用了compose的paging无法降级

liamyu commented 2 years ago

对demo做了一个简单升级,用于复现问题,在paging3分支: https: https://github.com/liamyu/imageviewer.git ssh: git@github.com:liamyu/imageviewer.git

iielse commented 2 years ago

imageviewer 内部实现已经升级到 paging3. 可以尝试 implementation 'com.github.iielse:imageviewer:2.1.13'

iielse commented 2 years ago

我自测了 全量加载. 动态加载 都没啥问题. 删除功能也可以用 @liamyu

liamyu commented 2 years ago

棒棒哒,给你点个赞!

iielse commented 2 years ago

帮我看下有没问题. 没问题合并到 master. 我自己看的应该没啥问题