-
Notifications
You must be signed in to change notification settings - Fork 554
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
Add subitem doesn't account for other expanded subitems #394
Comments
@gwailoTr0n5000, could you please explain better what is the cause of the problem of not adding subitems at the sub-position? From the comment in the code: that method expands parent if requested and not already expanded; Notify the adapter of the new addition to display it and animate it. If parent is collapsed there's no need to add sub items; Notify the parent about the change if requested. You may want to do this (with boolean added = false;
// Expand parent if requested and not already expanded
if (expandParent && !parent.isExpanded()) {
expand(parentPosition);
// Notify the adapter of the new addition to display it and animate it.
// If parent is collapsed there's no need to add sub items.
} else if (parent.isExpanded()) {
added = addItems(parentPosition + 1 + Math.max(0, subPosition), subItems);
// Notify the parent about the change if requested
if (payload != null) notifyItemChanged(parentPosition, payload);
}
return added; Basically, the method is an helper of what you had to do if expandable is expanded or not. Regarding collapsing, a recursive collapse is already done. |
I'm sorry for not doing a better job earlier. I will do an example below. Header
if adding at position 5 (where "s 3" is currently), the insert I see is the following: Desired:Header
Actual:Header
The flat position is 3 if the sub-subitems (ss 1 and ss2) are not considered, however the true position actually requires adding position + recursive(num of sub items) before the insert position. Perhaps I have called the incorrect method? |
Ok, I see the issue now. It should count expanded subItems recursively. When I created that method I didn't update for multilevel, indeed it doesn't support it and should be fixed. |
I'll take a shot at it. It seems the places to add this at the moment are within the following two methods:
and
If anything else comes to mind let me know and I'll include it in the pull request. Thanks! -Pedro |
Ok for me |
@gwailoTr0n5000, are you going to make the pull request? |
Initial changes led to another issue which I'm debugging this morning. Will
update you as soon as possible.
…On Tue, Jun 27, 2017 at 7:19 AM Davide Steduto ***@***.***> wrote:
@gwailoTr0n5000 <https://github.com/gwailotr0n5000>, are you going to
make the pull request?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#394 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABwHW9fgFBYWYJNfbyTeB1v-hoANSbLMks5sIPMdgaJpZM4OC2E4>
.
|
I've been able to get it most of the way but am ending up with inconsistencies in some cases causing crashes, the mPosiion is greater than the adapter count:
My branch is here if you'd like to take a look: |
Figured it out, was using a recursive call in prepareItemsForUpdate that is unnecessary as that method already traverses through subitems as they expand. Pull request being sent now. |
Thanks to this fix/code improvement we can now add a new feature see #401. |
Excellent! That was something we were considering for the future. |
In our latest round of testing we've found another small bug with regard to adding subitems. Additions work well except in the case that the incoming item is being placed after another subitem that itself is expanded. In this case, the position does not account for the additional flat list positions occupied by the children and the incoming item is placed either between the sub-subitems or in another incorrect position of the list.
I've tracked the relevant code down to the following:
Jump to code in GitHub
A similar issue occurs when an expandable item H is expanded followed by the expansion of a subitem and then the collapse of the top expandable item H. The collapse only removes k items where k = the number of direct subitems for the expandable item H. A method to quickly return the total number of visible subitems (recursively counting expansions when present) seems most useful to help handle these cases. Does such a method exist? Perhaps I missed it? If not, I'm happy to try my hand at a version but the modifications will be more significant than my last effort and I appreciate your input with regards to other areas where issues may arise due to this bug.
Thanks!
P.S. I can submit the expansion count bug as a separate issue or append it here if you prefer since they are similar.
The text was updated successfully, but these errors were encountered: