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

Address various concerns #808

Merged
merged 6 commits into from Jul 6, 2019
Merged

Address various concerns #808

merged 6 commits into from Jul 6, 2019

Conversation

mikepenz
Copy link
Owner

@mikepenz mikepenz commented Jul 6, 2019

This PR fixes various concerns as raised:
#801
#805
#806

It also includes some other smaller changes like proper experimental flag usage, and re-add back the DSL marker.

Also change to use asSequence and make those functions return lists instead of an array (no reason why it would require to be an array, also asSequence has no direct asIntArray function)

cc @AllanWang

* fix experimental annotation for new DSL API entrance points
* add inline to various methods
…tArray, and I think we don't need to go via a list to an array in this case if we don't really require an array)

* breaking change...
/**
* internal helper function to execute the block if the item is expandable
*/
internal fun <R> IItem<out RecyclerView.ViewHolder>?.ifExpandable(block: (IExpandable<*>) -> R): R? {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to make this a inline function?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I had it as an inline function. but AS will inform that the performance impact is rather low and it is suggested to keep it a normal function

Copy link
Contributor

Choose a reason for hiding this comment

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

Weird. I thought all inlined higher order functions benefit from inlining (performance wise). I'm not sure if it's because of let, which probably inlines stuff on its own

/**
* internal helper function to execute the block if the item is expandable
*/
internal fun <R> IItem<out RecyclerView.ViewHolder>?.ifExpandableParent(block: (IExpandable<*>, IParentItem<*>) -> R): R? {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to make this a inline function?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I had it as an inline function. but AS will inform that the performance impact is rather low and it is suggested to keep it a normal function

/**
* internal helper function to check if an item is expanded.
*/
internal fun IItem<out RecyclerView.ViewHolder>?.isExpanded(): Boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we should use a extension function or property-.

Copy link
Owner Author

Choose a reason for hiding this comment

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

But if the property would be on the IItem then internal would prevent it from being accessible in the expandable module

Copy link
Contributor

Choose a reason for hiding this comment

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

It's possible to create extension properties not just functions.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I have no strong opinion on this here. Feel free to adjust :)

Copy link
Owner Author

Choose a reason for hiding this comment

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

ok went ahead and changed it :D

@mikepenz mikepenz merged commit 8fdccfd into develop Jul 6, 2019
/**
* internal helper function to check if an item is expanded.
*/
val IItem<out RecyclerView.ViewHolder>?.isExpanded: Boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

@mikepenz wait so did you decide for this to be internal or not? This is currently public

Copy link
Contributor

Choose a reason for hiding this comment

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

As per your previous comment, I'm not sure why an internal val would not be accessible in the module from which it is declared

Copy link
Owner Author

Choose a reason for hiding this comment

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

oops the internal got lost with me changing it to the property. You are absolutely right. will address this.

@@ -267,15 +286,15 @@ class ExpandableExtension<Item : GenericItem>(private val fastAdapter: FastAdapt
* @param position the global position of the current item
* @return a set with the global positions of all expanded items on the root level
*/
fun getExpandedItemsRootLevel(position: Int): IntArray {
val expandedItemsList = ArraySet<Int>()
fun getExpandedItemsRootLevel(position: Int): List<Int> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Breaking API change?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes. That's another reason to go for v4.1.x

I think the usage of this should be == 0, and migration should be super simple. (considered a new function and deprecate the old, but not sure if it is worth it)

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

Successfully merging this pull request may close these issues.

None yet

3 participants