Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain list state after config change #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Set the current tab to today only once on startup so that after a con…
…fig change, it won't change the user's currently selected tab
  • Loading branch information
josephkreiser committed Mar 9, 2020

Verified

This commit was signed with the committer’s verified signature.
SamWilsn Sam Wilson
commit 3e0b7748953b10cd97b56f4254d60b4d89b5a585
Original file line number Diff line number Diff line change
@@ -64,12 +64,14 @@ class SessionDateFragment : Fragment() {
binding.pager.adapter = adapter
adapter.mediateTabs(binding.tabs, binding.pager)

// Set the current tab to today
if (it.dates.isNotEmpty()) {
val today = dateFormat.format(Date())
val index = adapter.dates.indexOfFirst { it.id == today }
if (index >= 0) {
binding.pager.setCurrentItem(index, false)
if (savedInstanceState == null) {
// Set the current tab to today
if (it.dates.isNotEmpty()) {
val today = dateFormat.format(Date())
val index = adapter.dates.indexOfFirst { it.id == today }
if (index >= 0) {
binding.pager.setCurrentItem(index, false)
}
}
}
}