前回レイアウト調整したらスクロール位置が始端かどうかの判定がおかしくなってたバグの修正
This commit is contained in:
parent
b01ba02727
commit
4d1da660de
|
@ -6553,30 +6553,33 @@ class Column(
|
||||||
fireShowContent(reason = "mergeStreamingMessage", changeList = changeList)
|
fireShowContent(reason = "mergeStreamingMessage", changeList = changeList)
|
||||||
|
|
||||||
if(holder != null) {
|
if(holder != null) {
|
||||||
if(holder_sp == null) {
|
when {
|
||||||
// スクロール位置が先頭なら先頭にする
|
holder_sp == null -> {
|
||||||
log.d("mergeStreamingMessage: has VH. missing scroll position.")
|
// スクロール位置が先頭なら先頭にする
|
||||||
viewHolder?.scrollToTop()
|
log.d("mergeStreamingMessage: has VH. missing scroll position.")
|
||||||
|
viewHolder?.scrollToTop()
|
||||||
|
}
|
||||||
|
|
||||||
} else if(holder_sp.adapterIndex == 0 && holder_sp.offset == 0) {
|
holder_sp.isHead -> {
|
||||||
// スクロール位置が先頭なら先頭にする
|
// スクロール位置が先頭なら先頭にする
|
||||||
log.d(
|
log.d("mergeStreamingMessage: has VH. keep head. $holder_sp")
|
||||||
"mergeStreamingMessage: has VH. keep head. offset=%s,offset=%s"
|
holder.setScrollPosition(ScrollPosition(0, 0))
|
||||||
, holder_sp.adapterIndex
|
}
|
||||||
, holder_sp.offset
|
|
||||||
)
|
restore_idx < - 1 ->{
|
||||||
holder.setScrollPosition(ScrollPosition(0, 0))
|
// 可視範囲の検出に失敗
|
||||||
} else if(restore_idx < - 1) {
|
log.d("mergeStreamingMessage: has VH. can't get visible range.")
|
||||||
// 可視範囲の検出に失敗
|
}
|
||||||
log.d("mergeStreamingMessage: has VH. can't get visible range.")
|
|
||||||
} else {
|
else -> {
|
||||||
// 現在の要素が表示され続けるようにしたい
|
// 現在の要素が表示され続けるようにしたい
|
||||||
log.d("mergeStreamingMessage: has VH. added=$added")
|
log.d("mergeStreamingMessage: has VH. added=$added")
|
||||||
holder.setListItemTop(restore_idx + added, restore_y)
|
holder.setListItemTop(restore_idx + added, restore_y)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val scroll_save = this@Column.scroll_save
|
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 {
|
} else {
|
||||||
// 現在の要素が表示され続けるようにしたい
|
// 現在の要素が表示され続けるようにしたい
|
||||||
|
|
|
@ -6,8 +6,15 @@ import jp.juggler.subwaytooter.ColumnViewHolder
|
||||||
class ScrollPosition {
|
class ScrollPosition {
|
||||||
|
|
||||||
var adapterIndex : Int
|
var adapterIndex : Int
|
||||||
|
|
||||||
|
// 先頭要素のピクセルオフセット。 通常は <= 0 だが、topMarginがある場合は >0 になりうる
|
||||||
val offset : Int
|
val offset : Int
|
||||||
|
|
||||||
|
val isHead : Boolean
|
||||||
|
get() = adapterIndex == 0 && offset >= 0
|
||||||
|
|
||||||
|
override fun toString() : String ="ScrlPos($adapterIndex,$offset)"
|
||||||
|
|
||||||
constructor(adapterIndex : Int, top : Int) {
|
constructor(adapterIndex : Int, top : Int) {
|
||||||
this.adapterIndex = adapterIndex
|
this.adapterIndex = adapterIndex
|
||||||
this.offset = top
|
this.offset = top
|
||||||
|
|
Loading…
Reference in New Issue