-
Notifications
You must be signed in to change notification settings - Fork 551
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: back button in actionbar #1442
fix: back button in actionbar #1442
Conversation
Details: Previously, when error fetching is displayed, other menu item in actionbar is hided by setting setActionMenu to false. This made the android.R.id.home menu item stop working. So instead of setting the hasActionMenu to false, setting the menu item visibility to false solve problem Fixes: #1436
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
val menuItemSize = menuActionBar?.size() ?: 0 | ||
for (i in 0..(menuItemSize - 1)) { | ||
menuActionBar?.getItem(i)?.isVisible = !show | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And when we go back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but I don't really understand your question? @iamareebjamal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it reappear correctly when we go back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand, it will reappear correctly because:
- Menu Items visibility will only change on function
showEventErrorScreen()
- When error fetching occurs, the error is observed and call that function
showEventErrorScreen()
to true -> menu items visibility is false -> disappear - When error fetching stop occurring, the event detail is fetched and the
event
variable in the ViewModel is observed and call that functionshowEventErrorScreen()
to false -> menu items visibility is true -> reappear
You can see it in here from line 84 to 104
eventViewModel.event
.nonNull()
.observe(this, Observer {
loadEvent(it)
eventShare = it
title = eventShare.name
if (eventShare.favorite) {
setFavoriteIcon(R.drawable.ic_baseline_favorite_white)
}
if (runOnce) {
loadSocialLinksFragment()
loadSimilarEventsFragment()
}
runOnce = false
Timber.d("Fetched events of id %d", safeArgs.eventId)
showEventErrorScreen(false)
setHasOptionsMenu(true)
})
Details:
Previously, when the error fetching message is displayed, the other menu items in the action bar are hided by setting setHasOptionMenu to false. This made the android.R.id.home menu item stop working.
So instead of setting the setHasOptionMenu to false, setting the menu item visibility to false solve problem
Fixes: #1436
Screenshots for the change:
![](https://camo.githubusercontent.com/b3ff715c80f617065d2344a0e024b9c1d9c912a6b0e328b69b282429469426b2/68747470733a2f2f692e6962622e636f2f466e4d784876312f657a6769662d322d3032386230346434643136322e676966)