mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
Add a ZeroItem to avoid automatic scroll when the breadcrumbs are updated from another client
This commit is contained in:
parent
123ffe9f9c
commit
7eae85a394
3 changed files with 40 additions and 1 deletions
30
vector/src/main/java/im/vector/riotx/core/epoxy/ZeroItem.kt
Normal file
30
vector/src/main/java/im/vector/riotx/core/epoxy/ZeroItem.kt
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright 2019 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.riotx.core.epoxy
|
||||
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.riotx.R
|
||||
|
||||
/**
|
||||
* Item of size (0, 0).
|
||||
* It can be useful to avoid automatic scroll of RecyclerView with Epoxy controller, when the first valuable item changes.
|
||||
*/
|
||||
@EpoxyModelClass(layout = R.layout.item_zero)
|
||||
abstract class ZeroItem : VectorEpoxyModel<ZeroItem.Holder>() {
|
||||
|
||||
class Holder : VectorEpoxyHolder()
|
||||
}
|
|
@ -19,6 +19,7 @@ package im.vector.riotx.features.home.room.breadcrumbs
|
|||
import android.view.View
|
||||
import com.airbnb.epoxy.EpoxyController
|
||||
import im.vector.matrix.android.api.util.toMatrixItem
|
||||
import im.vector.riotx.core.epoxy.zeroItem
|
||||
import im.vector.riotx.core.utils.DebouncedClickListener
|
||||
import im.vector.riotx.features.home.AvatarRenderer
|
||||
import javax.inject.Inject
|
||||
|
@ -45,9 +46,13 @@ class BreadcrumbsController @Inject constructor(
|
|||
override fun buildModels() {
|
||||
val safeViewState = viewState ?: return
|
||||
|
||||
// Add a ZeroItem to avoid automatic scroll when the breadcrumbs are updated from another client
|
||||
zeroItem {
|
||||
id("top")
|
||||
}
|
||||
|
||||
// An empty breadcrumbs list can only be temporary because when entering in a room,
|
||||
// this one is added to the breadcrumbs
|
||||
|
||||
safeViewState.asyncBreadcrumbs.invoke()
|
||||
?.forEach {
|
||||
breadcrumbsItem {
|
||||
|
|
4
vector/src/main/res/layout/item_zero.xml
Normal file
4
vector/src/main/res/layout/item_zero.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<View xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp" />
|
Loading…
Reference in a new issue