diff --git a/vector/src/main/java/im/vector/riotx/core/epoxy/ZeroItem.kt b/vector/src/main/java/im/vector/riotx/core/epoxy/ZeroItem.kt new file mode 100644 index 0000000000..b64abdcc6c --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/core/epoxy/ZeroItem.kt @@ -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() { + + class Holder : VectorEpoxyHolder() +} diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsController.kt b/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsController.kt index bfc91bf5a1..3b77835917 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsController.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsController.kt @@ -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 { diff --git a/vector/src/main/res/layout/item_zero.xml b/vector/src/main/res/layout/item_zero.xml new file mode 100644 index 0000000000..ec7c4e3f98 --- /dev/null +++ b/vector/src/main/res/layout/item_zero.xml @@ -0,0 +1,4 @@ + +