前回レイアウト調整したらスクロール位置が始端かどうかの判定がおかしくなってたバグの修正

This commit is contained in:
tateisu 2018-11-26 00:11:25 +09:00
parent b01ba02727
commit 4d1da660de
2 changed files with 31 additions and 21 deletions

View File

@ -6553,30 +6553,33 @@ class Column(
fireShowContent(reason = "mergeStreamingMessage", changeList = changeList)
if(holder != null) {
if(holder_sp == null) {
// スクロール位置が先頭なら先頭にする
log.d("mergeStreamingMessage: has VH. missing scroll position.")
viewHolder?.scrollToTop()
} else if(holder_sp.adapterIndex == 0 && holder_sp.offset == 0) {
// スクロール位置が先頭なら先頭にする
log.d(
"mergeStreamingMessage: has VH. keep head. offset=%s,offset=%s"
, holder_sp.adapterIndex
, holder_sp.offset
)
holder.setScrollPosition(ScrollPosition(0, 0))
} else if(restore_idx < - 1) {
// 可視範囲の検出に失敗
log.d("mergeStreamingMessage: has VH. can't get visible range.")
} else {
// 現在の要素が表示され続けるようにしたい
log.d("mergeStreamingMessage: has VH. added=$added")
holder.setListItemTop(restore_idx + added, restore_y)
when {
holder_sp == null -> {
// スクロール位置が先頭なら先頭にする
log.d("mergeStreamingMessage: has VH. missing scroll position.")
viewHolder?.scrollToTop()
}
holder_sp.isHead -> {
// スクロール位置が先頭なら先頭にする
log.d("mergeStreamingMessage: has VH. keep head. $holder_sp")
holder.setScrollPosition(ScrollPosition(0, 0))
}
restore_idx < - 1 ->{
// 可視範囲の検出に失敗
log.d("mergeStreamingMessage: has VH. can't get visible range.")
}
else -> {
// 現在の要素が表示され続けるようにしたい
log.d("mergeStreamingMessage: has VH. added=$added")
holder.setListItemTop(restore_idx + added, restore_y)
}
}
} else {
val scroll_save = this@Column.scroll_save
if(scroll_save == null || (scroll_save.adapterIndex == 0 && scroll_save.offset == 0)) {
if(scroll_save == null || scroll_save.isHead ) {
// スクロール位置が先頭なら先頭のまま
} else {
// 現在の要素が表示され続けるようにしたい

View File

@ -6,8 +6,15 @@ import jp.juggler.subwaytooter.ColumnViewHolder
class ScrollPosition {
var adapterIndex : Int
// 先頭要素のピクセルオフセット。 通常は <= 0 だが、topMarginがある場合は >0 になりうる
val offset : Int
val isHead : Boolean
get() = adapterIndex == 0 && offset >= 0
override fun toString() : String ="ScrlPos($adapterIndex,$offset)"
constructor(adapterIndex : Int, top : Int) {
this.adapterIndex = adapterIndex
this.offset = top