I have this code inside onCreate
inside an activity:
week_info.setOnClickListener { v ->
ChangeWeekDialogFragment.newInstance(weekPagerAdapter.displayedWeek) { week ->
week_view_pager.currentItem += week.weeksBetween(weekPagerAdapter.displayedWeek)
}.show(supportFragmentManager, "ChangeWeekDialogFragment")
}
The lambda passed into the newInstance
function executes when a new week is set inside the ChangeWeekDialogFragment
.
The problem is that whenever there's an orientation change while the ChangeWeekDialogFragment
is shown and then I change the week, it's as if the line inside the lambda expression wasn't called because the ViewPager doesn't change its displayed item. What's strange though, is that the line week_view_pager.currentItem += week.weeksBetween(weekPagerAdapter.displayedWeek)
actually gets called when I set a breakpoint on it.
With no orientation change while the ChangeWeekDialogFragment
is opened, everything works as you'd expect.
Thank you!