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 Fragments not loading ViewModel after App killed in background #4550

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

Cheesebaron
Copy link
Member

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

Bug fix

⤵️ What is the current behavior?

  1. Set "Don't keep activities" in Developer options to true
  2. Launch the playground app
  3. Click "SHOW CHILD" button
  4. Navigate to a different app
  5. Come back
  6. ViewModel is null for the Child Fragment

This is due to MvxBindingFragmentAdapter always relying on the Android bundle having saved state, but Android could kill the App in background without going through OnDestroy and related calls.

🆕 What is the new behavior (if this is a feature change)?

Instead of checking for bundle, I am relying on whether ViewModel is null, at this point it will mean, that we didn't navigate to the Fragment using the Presenter and we should load a ViewModel for the Fragment without going to the Presenter.

💥 Does this PR introduce a breaking change?

No

🐛 Recommendations for testing

See steps above

📝 Links to relevant issues/docs

🤔 Checklist before submitting

@Cheesebaron Cheesebaron added t/bug Bug type p/android Android platform labels Jan 16, 2023
@sonarcloud
Copy link

sonarcloud bot commented Jan 16, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@Cheesebaron Cheesebaron merged commit c07a59d into develop Jan 16, 2023
@Cheesebaron Cheesebaron deleted the bugfix/fragment-rehydration branch January 16, 2023 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p/android Android platform t/bug Bug type
Development

Successfully merging this pull request may close these issues.

None yet

1 participant