Skip to content

Commit a963671

Browse files
committed
fix: subscriptions feed scroll state reset after rotating phone
1 parent 9318a2b commit a963671

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.libretube.ui.fragments
22

33
import android.annotation.SuppressLint
4+
import android.content.res.Configuration
45
import android.os.Bundle
56
import android.view.View
67
import android.view.ViewGroup.MarginLayoutParams
@@ -440,6 +441,13 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
440441
binding.toggleSubs.text = "${getString(R.string.subscriptions)} ($subCount)"
441442
}
442443

444+
override fun onConfigurationChanged(newConfig: Configuration) {
445+
super.onConfigurationChanged(newConfig)
446+
// manually restore the recyclerview state after rotation due to https://github.com/material-components/material-components-android/issues/3473
447+
binding.subChannels.layoutManager?.onRestoreInstanceState(viewModel.subChannelsRecyclerViewState)
448+
binding.subFeed.layoutManager?.onRestoreInstanceState(viewModel.subFeedRecyclerViewState)
449+
}
450+
443451
fun removeItem(videoId: String) {
444452
feedAdapter.removeItemById(videoId)
445453
}

0 commit comments

Comments
 (0)