-
Notifications
You must be signed in to change notification settings - Fork 7.4k
refactor(admob): use Jetpack's Navigation Component #1247
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
refactor(admob): use Jetpack's Navigation Component #1247
Conversation
@rosariopfernandes thank you for doing this and for looking out for the snippet changes. I'll need to do some internal work to make sure we don't break the docs when we submit this, so that will delay things a bit. |
@samtstern I noticed the |
@rosariopfernandes yeah eventually I want to get all of the snippets out of this repo and into snippets-android (unless they're special ones like AndroidManifest.xml snippets). If you're willing to make that PR that would be great! You can drop anything in a |
@samtstern What's special about AndroidManifest.xml snippets? I think I saw a snippet in the admob's Manifest. I wonder if maybe I shouldn't move it? One more question: When moving the snippets, should we keep using Activities? Or do we switch to Fragments? |
@rosariopfernandes there's nothing really special about them but they're sometimes hard to "compile" in the snippets repo, having them in a real app makes them more likely to be correct. If they're tied to the Java code in the snippets repo though then it's totally fine to move them there as well. As for the Fragment thing I'd suggest just separating out a variable, so if you previously had this in an activity:
Instead we could do:
Which should make it clear to the developer that any |
@samtstern Ah, I see. I'll be sure to watch out for that. Thanks That Context solution sounds great! I'll do that. |
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 looks great! Just waiting on it to be safe for snippets (internal change pending)
Internal change merged so now I can merge this one as well! |
Kicking Off step 2 of #1217 : Navigation Component ✨
This PR should replace the 2 activities in Admob with 2 fragments (
FirstFragment
andSecondFragment
) and link them using the Navigation Component.The navigation graph is simple:
Some code changes that I should point out:1. There were snippets in theMainActivity.java
which were moved toFirstFragment.java
2. Snippets inMainActivity.kt
were moved toFirstFragment.kt
3. Snippets inactivity_main.xml
were moved tofragment_first.xml
4. The methodbeginSecondActivity
was renamed togoToNextFragment
We're moving the snippets from this repo to firebase/snippets-android. See firebase/snippets-android#272
I was unsure of what to do with the tests, since they make use of Activities.
I tried replacing it with the code I found in Test your Fragments, but I'm not sure if it even works.