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

androidx: started migration #162

Closed
wants to merge 1 commit into from

Conversation

alashow
Copy link

@alashow alashow commented Aug 9, 2018

Resolves #161

Had a couple of issues with tests and null handling that needs to be improved. Marked with TODO and will add comments in review.


testImplementation "junit:junit:$rootProject.ext.junitVersion"
testImplementation "org.mockito:mockito-core:2.13.0"
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.0.0-alpha03"
testImplementation "org.robolectric:robolectric:3.7"
testImplementation 'org.robolectric:robolectric:4.0-alpha-3-SNAPSHOT'
Copy link
Author

Choose a reason for hiding this comment

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

Had to upgrade to 4.0 because 3.x didn't support API 28

Choose a reason for hiding this comment

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

4.1.0 stable is available now

@@ -118,7 +126,7 @@ class FragNavController constructor(private val fragmentManger: FragmentManager,
} else {
//Else try to find one in the FragmentManager
val fragmentManager: FragmentManager = getFragmentManagerForDialog()
mCurrentDialogFrag = fragmentManager.fragments?.firstOrNull { it is DialogFragment } as DialogFragment?
mCurrentDialogFrag = fragmentManager.fragments.firstOrNull { it is DialogFragment } as DialogFragment?
Copy link
Author

Choose a reason for hiding this comment

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

The compiler was suggesting to remove safe calls as they're not nullable anymore.

@@ -277,7 +285,11 @@ class FragNavController constructor(private val fragmentManger: FragmentManager,
} else {
fragment = getRootFragment(currentStackIndex)
// Handle special case of indexes, restore tag of removed fragment
var tag = fragment.tag ?: fragmentStacksTags[index].peek()
var tag = fragment.tag
// TODO: Better empty stack handling
Copy link
Author

Choose a reason for hiding this comment

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

This one was throwing StackEmptyException in NavDrawer example (NavDrawer example > Open NavDrawer > Click any menu) and in tests.

// TODO: Better null handling
if (sharedElement.first != null) {
addSharedElement(
sharedElement.first!!,
Copy link
Author

Choose a reason for hiding this comment

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

addSharedElement now requires a non-null view.

Choose a reason for hiding this comment

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

The safest way to do sharedElement.first!! is either calling firstOrNull() like sharedElement?.firstOrNull() or to getOrNull(0)

@alashow
Copy link
Author

alashow commented Sep 20, 2018

What do you mean it's good? They are same support libraries with different name and package.
It's going to be breaking change anyway, so why wait?

@mateherber
Copy link
Contributor

@alashow Please refer to #178
In that I've done the migration to androidX on top of 3.0.0

@ncapdevi
Copy link
Owner

@alashow thank you for the PR and sorry for the delay. As @mateherber mentioned, this migration has been included in #178 and will be released as part of 3.1.0 #187 Apologies for not getting to this sooner and your help is appreciated!

@ncapdevi ncapdevi closed this Dec 21, 2018
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.

4 participants