RocketChat / Rocket.Chat.Android

Legacy mobile Rocket.Chat client in Kotlin for Android
https://rocket.chat
MIT License
869 stars 555 forks source link

[IMPROVEMENT] Keep the scroll position in ChatRoomFragment after rotating screen. #2123

Open divyanshub024 opened 5 years ago

Arnesh07 commented 5 years ago

Hello,I picked this issue and researched a bit.What I learnt was that when we scroll,the onScrolled function is called and the scroll stage is stored in the verticalScrollOffset variable.Now after the device's orientation is changed,what I would be wanting is to restore the value of verticalScrollOffset to the initial value. For this I would want to recover the value of verticalScrollOffset from onSavedInstanceState. Now can you recommend me a way of doing so or any other method you have in mind of solving the problem. I read somewhere that android have inbuilt features to restore the state of recyclerView but I am unable to get the documentation of it. @divyanshub024

divyanshub024 commented 5 years ago

@Arnesh07 I did this for chatRoomsFragment check it in #2124 but chatRoomFragment is does not use MVVM so we cannot use it here. Other option can be saving the position in onSavedInstanceState but I don't know if that is the correct way. Maybe @filipedelimabrito can tell the perfect way of doing this.