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

Fix part of 405 #408

Merged
merged 1 commit into from
Nov 18, 2019
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class StateFragmentPresenter @Inject constructor(
private var showCellularDataDialog = true
private var useCellularData = false
private lateinit var explorationId: String
private lateinit var currentStateName: String
private var currentStateName: String = ""
private lateinit var binding: StateFragmentBinding
private lateinit var recyclerViewAdapter: RecyclerView.Adapter<*>
private lateinit var viewModel: StateViewModel
Expand Down Expand Up @@ -280,6 +280,12 @@ class StateFragmentPresenter @Inject constructor(
}

val ephemeralState = result.getOrThrow()

var scrollToTop = false
if (currentStateName.isNotEmpty() && currentStateName != ephemeralState.state.name) {
scrollToTop = true
}

currentStateName = ephemeralState.state.name
val pendingItemList = mutableListOf<StateItemViewModel>()
addContentItem(pendingItemList, ephemeralState)
Expand Down Expand Up @@ -315,7 +321,10 @@ class StateFragmentPresenter @Inject constructor(

viewModel.itemList.clear()
viewModel.itemList += pendingItemList
binding.stateRecyclerView.smoothScrollToPosition(0)

if (scrollToTop) {
binding.stateRecyclerView.smoothScrollToPosition(0)
}
}

/**
Expand Down