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 funtionality of the app #804
fix: back funtionality of the app #804
Conversation
the issue was in onBackPresses in main activity if the rootFragment is other than EventFragment it will assume that it is Main page which will be wrong in all other cases like TicketFragment, AttendeeFragment, OrderDetailsFragment, it was calling EventFragment finish method which was closing our app , so add conditions for these Fragments too. issue:fossasia#726
app/src/main/java/org/fossasia/openevent/general/MainActivity.kt
Outdated
Show resolved
Hide resolved
is TicketsFragment, | ||
is AttendeeFragment, | ||
is OrderDetailsFragment -> super.onBackPressed() | ||
else -> when (currentFragment) { |
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.
Both when conditions can be written separately. Let mentors review it.
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.
This is massive duplication
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.
@iamareebjamal how about this the rootFragment is null when we are in the main page so
if (rootFragment == null) {
when (currentFragment) {
is SearchFragment,
is FavoriteFragment,
is OrdersUnderUserFragment,
is ProfileFragment -> {
loadFragment(supportFragmentManager, EventsFragment(), frameContainer.id)
navigation.selectedItemId = navigation_events
}
is EventsFragment -> finish()
else -> super.onBackPressed()
}
}
else super.onBackPressed()
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.
Seems better but reverse the condition and use early return
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.
@iamareebjamal like this
if (rootFragment != null) {
super.onBackPressed()
return
}
when (currentFragment) {
is SearchFragment,
is FavoriteFragment,
is OrdersUnderUserFragment,
is ProfileFragment -> {
loadFragment(supportFragmentManager, EventsFragment(), frameContainer.id)
navigation.selectedItemId = navigation_events
}
is EventsFragment -> finish()
else -> super.onBackPressed()
}
}
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.
Yes
@pranavpandey1998official This issue is solved in PR #823 with navigation. Sorry for it. onBackPressed method is not required anymore. |
Fixes #726
the issue was in onBackPresses in main activity if the rootFragment is other than EventFragment it will assume that it is Main page which will be wrong in all other cases like TicketFragment, AttendeeFragment, OrderDetailsFragment, it was calling EventFragment finish method which was closing our app , so add conditions for these Fragments too.