Skip to content

Commit

Permalink
fix topic expand
Browse files Browse the repository at this point in the history
  • Loading branch information
ekibun committed Mar 4, 2019
1 parent 3293309 commit b850d76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class TopicPresenter(private val context: TopicActivity) {

private val ua by lazy { WebView(context).settings.userAgentString }
fun getTopic(scrollPost: String = ""){
context.item_swipe.isRefreshing = true
Bangumi.getTopic(context.openUrl, ua).enqueue(ApiHelper.buildCallback(context, {topic->
processTopic(topic, scrollPost)
}){context.item_swipe.isRefreshing = false})
Expand Down Expand Up @@ -151,6 +152,7 @@ class TopicPresenter(private val context: TopicActivity) {
main.forEach {
it.value.floor = (replies.last()?.floor?:0)+1
it.value.relate = it.key
it.value.isExpanded = replies.firstOrNull { o-> o.pst_id == it.value.pst_id }?.isExpanded?: true
replies.removeAll { o-> o.pst_id == it.value.pst_id }
replies.add(it.value)
//adapter.addData(it.value)
Expand Down
13 changes: 11 additions & 2 deletions app/src/main/java/soko/ekibun/bangumi/ui/topic/TopicView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class TopicView(private val context: TopicActivity){
.apply(RequestOptions.bitmapTransform(BlurTransformation(25, 8)))
.into(context.item_cover_blur)
adapter.isUseEmpty(true)
topic.replies.forEach { it.isExpanded = true }
setNewData(topic.replies)
(context.item_list?.layoutManager as? LinearLayoutManager)?.let{ layoutManager ->
layoutManager.scrollToPositionWithOffset(adapter.data.indexOfFirst { it.pst_id == scrollPost }, 0) }
Expand Down Expand Up @@ -122,7 +123,6 @@ class TopicView(private val context: TopicActivity){
if(subFloor == 0) {
referPost = it
referPost?.subItems?.clear()
it.isExpanded = false
true
}
else {
Expand All @@ -131,6 +131,15 @@ class TopicView(private val context: TopicActivity){
false
}
})
adapter.expandAll()
var i = 0
while(i< adapter.data.size){
val topicPost = adapter.data[i]
if(topicPost.isExpanded){
topicPost.isExpanded = false
adapter.expand(i, false, false)
}
i++
}
//adapter.expandAll()
}
}

0 comments on commit b850d76

Please sign in to comment.