fix: subscriptions feed scroll state reset after rotating phone

This commit is contained in:
Bnyro 2025-04-01 10:33:10 +02:00
parent 9318a2b277
commit a96367139a
No known key found for this signature in database

View File

@ -1,6 +1,7 @@
package com.github.libretube.ui.fragments
import android.annotation.SuppressLint
import android.content.res.Configuration
import android.os.Bundle
import android.view.View
import android.view.ViewGroup.MarginLayoutParams
@ -440,6 +441,13 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
binding.toggleSubs.text = "${getString(R.string.subscriptions)} ($subCount)"
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
// manually restore the recyclerview state after rotation due to https://github.com/material-components/material-components-android/issues/3473
binding.subChannels.layoutManager?.onRestoreInstanceState(viewModel.subChannelsRecyclerViewState)
binding.subFeed.layoutManager?.onRestoreInstanceState(viewModel.subFeedRecyclerViewState)
}
fun removeItem(videoId: String) {
feedAdapter.removeItemById(videoId)
}