Skip to content

Commit

Permalink
阅读列明列表刷新,用错了方法,,导致最后一个章节的内容加载不出来,已修复
Browse files Browse the repository at this point in the history
  • Loading branch information
lang-v committed Nov 10, 2020
1 parent 6d9cce4 commit d39426f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Binary file modified app/release/app-release.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,10 @@ class ReadActivity : AppCompatActivity(), IBaseView, CustomSeekBar.OnProgressCha
}
if (index in 0 until contentViewModel.getList().size) {
val item = contentViewModel.getList()[index]
//避免重复加载
readHead.text = item.name
if (item.chapterId == currentReadID)return
currentReadID = item.chapterId
super.onScrolled(recyclerView, dx, dy)
if (index == contentViewModel.getList().size - 1) {
if (contentViewModel.getList()[index].nid != -1L) {
contentViewModel.cancelPrepare()
Expand All @@ -373,6 +374,7 @@ class ReadActivity : AppCompatActivity(), IBaseView, CustomSeekBar.OnProgressCha
}
}
} else if (index == 0 && contentViewModel.getList()[0].pid != -1L) {
if (item.chapterId == currentReadID)return
contentViewModel.cancelPrepare()
if (!firstRun)
contentViewModel.prepareChapter(0)
Expand Down Expand Up @@ -704,19 +706,20 @@ class ReadActivity : AppCompatActivity(), IBaseView, CustomSeekBar.OnProgressCha
1 -> {
contentAdapter.notifyItemInserted(0)
}

2 -> {
contentAdapter.notifyItemInserted(contentAdapter.itemCount - 1)
}

3 -> {
contentAdapter.notifyItemChanged(contentAdapter.itemCount - 1)
contentAdapter.notifyItemInserted(contentAdapter.itemCount - 1)
// contentAdapter.notifyItemChanged()
//contentManager.scrollToPositionWithOffset(0, readOffset)
readList.scrollBy(0, -readOffset)
firstRun = false
//加载上下章节
contentViewModel.prepareChapter(0)
contentViewModel.prepareChapter(contentAdapter.itemCount-1)
firstRun = false
}
}
if (dialog.isShowing)
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/novel/qingwen/viewmodel/ReadVM.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class ReadVM : BaseVM(), ResponseCallback<ChapterContent> {
/**
* 小说文章加载时先从数据库中查找,没有缓存则网络请求,返回结果后将结果写入数据库
* @param attachStart 是否将加载的小说内容添加到集合头部
* @param count 加载几个章节 1:仅当前章节 2:当前章节和下一章 3:当前章节、上一章和下一章
*/
fun getChapter(chapterId: Long, attachStart: Boolean = false, slient: Boolean = false) {
GlobalScope.launch {
Expand Down

0 comments on commit d39426f

Please sign in to comment.