Jump to unread: removes unnecessary check which can cause scroll issue
This commit is contained in:
parent
ab37984beb
commit
cccf5de015
@ -20,7 +20,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import im.vector.app.core.platform.DefaultListUpdateCallback
|
import im.vector.app.core.platform.DefaultListUpdateCallback
|
||||||
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
|
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
|
||||||
import timber.log.Timber
|
|
||||||
import java.util.concurrent.atomic.AtomicReference
|
import java.util.concurrent.atomic.AtomicReference
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,19 +41,10 @@ class ScrollOnHighlightedEventCallback(private val recyclerView: RecyclerView,
|
|||||||
|
|
||||||
private fun scrollIfNeeded() {
|
private fun scrollIfNeeded() {
|
||||||
val eventId = scheduledEventId.get() ?: return
|
val eventId = scheduledEventId.get() ?: return
|
||||||
val positionToScroll = timelineEventController.searchPositionOfEvent(eventId)
|
val positionToScroll = timelineEventController.searchPositionOfEvent(eventId) ?: return
|
||||||
if (positionToScroll != null) {
|
recyclerView.stopScroll()
|
||||||
val firstVisibleItem = layoutManager.findFirstCompletelyVisibleItemPosition()
|
layoutManager.scrollToPosition(positionToScroll)
|
||||||
val lastVisibleItem = layoutManager.findLastCompletelyVisibleItemPosition()
|
scheduledEventId.set(null)
|
||||||
|
|
||||||
// Do not scroll it item is already visible
|
|
||||||
if (positionToScroll !in firstVisibleItem..lastVisibleItem) {
|
|
||||||
Timber.v("Scroll to $positionToScroll")
|
|
||||||
recyclerView.stopScroll()
|
|
||||||
layoutManager.scrollToPosition(positionToScroll)
|
|
||||||
}
|
|
||||||
scheduledEventId.set(null)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun scheduleScrollTo(eventId: String?) {
|
fun scheduleScrollTo(eventId: String?) {
|
||||||
|
Loading…
Reference in New Issue
Block a user