Skip to content

force set all items to adapter when wrap_content is set to RV, issues… #507

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ public class FlexboxLayoutManager extends RecyclerView.LayoutManager implements
/** The reference to the parent of the RecyclerView */
private View mParent;

/**
* if mFillAllItemsForced == true fixes all issues with "not all items displayed when wrap_content"
* issues: #349 #336 #339
*/
private Boolean mSetAllItemsForced = false;



/**
* Indicates the position that the view position that the flex line which has the view having
* this position needs to be recomputed before the next layout.
Expand Down Expand Up @@ -312,6 +320,14 @@ public void setFlexWrap(@FlexWrap int flexWrap) {
}
}

public Boolean getmSetAllItemsForced() {
Copy link

Choose a reason for hiding this comment

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

Better would be to have it here areAllItemsForced() or something similar.

return mSetAllItemsForced;
}

public void setmSetAllItemsForced(Boolean mSetAllItemsForced) {
Copy link

Choose a reason for hiding this comment

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

Same as above, naming needs correction.

this.mSetAllItemsForced = mSetAllItemsForced;
}

@JustifyContent
@Override
public int getJustifyContent() {
Expand Down Expand Up @@ -874,7 +890,8 @@ private void updateFlexLines(int childCount) {
// passed as 0 from the RecyclerView)
// Set the upper limit as the height of the device in order to prevent computing all
// items in the adapter
needsToFill = mLayoutState.mInfinite ?
// or set the mSetAllItemsForced to true to force all items to show
needsToFill = mSetAllItemsForced ? 999999999 : mLayoutState.mInfinite ?
Copy link

Choose a reason for hiding this comment

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

Maybe instead this 999999999 let's put Integer.MAX_VALUE ?

mContext.getResources().getDisplayMetrics().heightPixels
: mLayoutState.mAvailable;
} else {
Expand All @@ -885,7 +902,8 @@ private void updateFlexLines(int childCount) {
// passed as 0 from the RecyclerView)
// Set the upper limit as the width of the device in order to prevent computing all
// items in the adapter
needsToFill = mLayoutState.mInfinite ?
// or set the mSetAllItemsForced to true to force all items to show
needsToFill = mSetAllItemsForced ? 999999999 : mLayoutState.mInfinite ?
Copy link

Choose a reason for hiding this comment

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

Maybe instead this 999999999 let's put Integer.MAX_VALUE ?

mContext.getResources().getDisplayMetrics().widthPixels
: mLayoutState.mAvailable;
}
Expand Down