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: back funtionality of the app #804

Conversation

pranavpandey1998official
Copy link
Contributor

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.

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
@pranavpandey1998official pranavpandey1998official changed the title fixes:back funtionality of the app fix:back funtionality of the app Jan 2, 2019
@pranavpandey1998official pranavpandey1998official changed the title fix:back funtionality of the app fix: back funtionality of the app Jan 2, 2019
is TicketsFragment,
is AttendeeFragment,
is OrderDetailsFragment -> super.onBackPressed()
else -> when (currentFragment) {
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is massive duplication

Copy link
Contributor Author

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() 

Copy link
Member

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

Copy link
Contributor Author

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()
    }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@liveHarshit
Copy link
Member

liveHarshit commented Jan 3, 2019

@pranavpandey1998official This issue is solved in PR #823 with navigation. Sorry for it. onBackPressed method is not required anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants