Scroll to top on filter type changed.
This commit is contained in:
parent
42ade670da
commit
b5c6f60ee6
@ -199,7 +199,11 @@ class VectorSettingsDevicesFragment :
|
|||||||
} else {
|
} else {
|
||||||
views.deviceListHeaderOtherSessions.isVisible = true
|
views.deviceListHeaderOtherSessions.isVisible = true
|
||||||
views.deviceListOtherSessions.isVisible = true
|
views.deviceListOtherSessions.isVisible = true
|
||||||
views.deviceListOtherSessions.render(otherDevices.take(NUMBER_OF_OTHER_DEVICES_TO_RENDER), otherDevices.size)
|
views.deviceListOtherSessions.render(
|
||||||
|
devices = otherDevices.take(NUMBER_OF_OTHER_DEVICES_TO_RENDER),
|
||||||
|
totalNumberOfDevices = otherDevices.size,
|
||||||
|
showViewAll = otherDevices.size > NUMBER_OF_OTHER_DEVICES_TO_RENDER
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ package im.vector.app.features.settings.devices.v2.list
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.extensions.cleanup
|
import im.vector.app.core.extensions.cleanup
|
||||||
@ -42,8 +44,10 @@ class OtherSessionsView @JvmOverloads constructor(
|
|||||||
@Inject lateinit var otherSessionsController: OtherSessionsController
|
@Inject lateinit var otherSessionsController: OtherSessionsController
|
||||||
|
|
||||||
private val views: ViewOtherSessionsBinding
|
private val views: ViewOtherSessionsBinding
|
||||||
|
private val recyclerViewDataObserver: RecyclerView.AdapterDataObserver
|
||||||
var callback: Callback? = null
|
var callback: Callback? = null
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
inflate(context, R.layout.view_other_sessions, this)
|
inflate(context, R.layout.view_other_sessions, this)
|
||||||
views = ViewOtherSessionsBinding.bind(this)
|
views = ViewOtherSessionsBinding.bind(this)
|
||||||
@ -53,16 +57,30 @@ class OtherSessionsView @JvmOverloads constructor(
|
|||||||
views.otherSessionsViewAllButton.setOnClickListener {
|
views.otherSessionsViewAllButton.setOnClickListener {
|
||||||
callback?.onViewAllOtherSessionsClicked()
|
callback?.onViewAllOtherSessionsClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recyclerViewDataObserver = object : RecyclerView.AdapterDataObserver() {
|
||||||
|
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
|
||||||
|
super.onItemRangeInserted(positionStart, itemCount)
|
||||||
|
views.otherSessionsRecyclerView.scrollToPosition(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
otherSessionsController.adapter.registerAdapterDataObserver(recyclerViewDataObserver)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun render(devices: List<DeviceFullInfo>, totalNumberOfDevices: Int) {
|
fun render(devices: List<DeviceFullInfo>, totalNumberOfDevices: Int, showViewAll: Boolean) {
|
||||||
views.otherSessionsRecyclerView.configureWith(otherSessionsController, hasFixedSize = true)
|
views.otherSessionsRecyclerView.configureWith(otherSessionsController, hasFixedSize = true)
|
||||||
views.otherSessionsViewAllButton.text = context.getString(R.string.device_manager_other_sessions_view_all, totalNumberOfDevices)
|
if (showViewAll) {
|
||||||
|
views.otherSessionsViewAllButton.isVisible = true
|
||||||
|
views.otherSessionsViewAllButton.text = context.getString(R.string.device_manager_other_sessions_view_all, totalNumberOfDevices)
|
||||||
|
} else {
|
||||||
|
views.otherSessionsViewAllButton.isVisible = false
|
||||||
|
}
|
||||||
otherSessionsController.setData(devices)
|
otherSessionsController.setData(devices)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDetachedFromWindow() {
|
override fun onDetachedFromWindow() {
|
||||||
otherSessionsController.callback = null
|
otherSessionsController.callback = null
|
||||||
|
otherSessionsController.adapter.unregisterAdapterDataObserver(recyclerViewDataObserver)
|
||||||
views.otherSessionsRecyclerView.cleanup()
|
views.otherSessionsRecyclerView.cleanup()
|
||||||
super.onDetachedFromWindow()
|
super.onDetachedFromWindow()
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ class OtherSessionsFragment :
|
|||||||
} else {
|
} else {
|
||||||
views.deviceListOtherSessions.isVisible = true
|
views.deviceListOtherSessions.isVisible = true
|
||||||
views.otherSessionsNotFoundLayout.isVisible = false
|
views.otherSessionsNotFoundLayout.isVisible = false
|
||||||
views.deviceListOtherSessions.render(devices, devices.size)
|
views.deviceListOtherSessions.render(devices = devices, totalNumberOfDevices = devices.size, showViewAll = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:padding="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginEnd="8dp">
|
android:padding="8dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -109,8 +109,9 @@
|
|||||||
<im.vector.app.features.settings.devices.v2.list.OtherSessionsView
|
<im.vector.app.features.settings.devices.v2.list.OtherSessionsView
|
||||||
android:id="@+id/deviceListOtherSessions"
|
android:id="@+id/deviceListOtherSessions"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="32dp"
|
android:layout_marginTop="32dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/otherSessionsSecurityRecommendationView" />
|
app:layout_constraintTop_toBottomOf="@id/otherSessionsSecurityRecommendationView" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user