快照管理页批量删除支持自动快照,单卡删除保留滚动位置并修复瀑布流列归属 - #1076
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
快照管理页批量删除支持自动快照,单卡删除保留滚动位置并修复瀑布流列归属
背景
快照管理页的多选态此前只有“批量导出”一种语义:自动快照不可导出,因此在多选态中统一隐匿自动快照的勾选框、不允许选中。
但“批量删除”复用了这套导出多选态,导致自动快照也无法参与批量删除——即使自动快照本身支持单张删除,用户也只能一张张删。
另外,单卡删除时页面会
reload(resetScroll = true),每次删除都清空列表并回顶;改成保留滚动位置后,又暴露出StaggeredGridLayoutManager的 span 缓存问题:逐个删到最后一张时,最后一张可能仍停留在右列,不会自动换到左列。改动内容
1. 批量删除多选态允许自动快照
SnapshotListFragment新增includeAuto选择态开关:includeAuto = false,自动快照仍不显示勾选框、不可选中;includeAuto = true,自动快照显示勾选框,可参与批量删除。SnapshotAdapter增加selectionIncludesAuto,toggleSelection/selectAll/isAllSelected统一按“是否可勾选”判断。selectedCards()返回正式 + 自动快照的选中卡片;批量删除改用该方法。isAuto分别走AutoSnapshotRepository.deleteAuto/SnapshotRepository.delete。2. 单卡删除不再回顶
reload(resetScroll = true)改为reload(reflow = true):submitList(null)清空列表,保留当前滚动位置;3. 删除后重新分配 StaggeredGrid span
reload新增reflow参数。reflow = true时使用ListAdapter.submitList(list, commitCallback),在 diff 真正提交后调用:StaggeredGridLayoutManager的 span 缓存并重新布局,避免最后一张卡停在右列;同时不会清空列表、不会回顶。_binding?.snapshotList === snapshotList,防止 view 重建后操作旧 RecyclerView。涉及文件
app/src/main/java/ceui/pixiv/snapshot/SnapshotListFragment.ktapp/src/main/java/ceui/pixiv/snapshot/SnapshotManagerFragment.kt提交
e297880efix(snapshot): 批量删除支持自动快照,单卡删除保留滚动并重排瀑布流列