Merge pull request #7268 from Bnyro/master

fix: subscriptions feed scroll state reset after rotating phone
This commit is contained in:
Bnyro 2025-04-01 10:33:52 +02:00 committed by GitHub
commit 5b7788bfd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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)
}