Skip to content

Commit fcb7490

Browse files
committed
fix issue with challenge list when rotated
1 parent 9d0a027 commit fcb7490

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/social/challenges/ChallengeListFragment.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ class ChallengeListFragment :
7676
savedInstanceState: Bundle?
7777
) {
7878
super.onViewCreated(view, savedInstanceState)
79+
if (savedInstanceState?.containsKey("viewUserChallengesOnly") == true) {
80+
viewUserChallengesOnly = savedInstanceState.getBoolean("viewUserChallengesOnly")
81+
}
7982

8083
challengeAdapter = ChallengesListViewAdapter(viewUserChallengesOnly, userViewModel.userID)
8184
challengeAdapter?.onOpenChallengeFragment = { openDetailFragment(it) }
@@ -129,6 +132,12 @@ class ChallengeListFragment :
129132
retrieveChallengesPage(true)
130133
}
131134

135+
override fun onSaveInstanceState(outState: Bundle) {
136+
outState.putBoolean("viewUserChallengesOnly", viewUserChallengesOnly)
137+
super.onSaveInstanceState(outState)
138+
139+
}
140+
132141
private fun openDetailFragment(challengeID: String) {
133142
MainNavigationController.navigate(
134143
ChallengesOverviewFragmentDirections.openChallengeDetail(

0 commit comments

Comments
 (0)