Skip to content

Commit

Permalink
force set all items to adapter when wrap_content is set to RV, issues f…
Browse files Browse the repository at this point in the history
  • Loading branch information
panic777 committed Aug 28, 2019
1 parent 7bf1ce7 commit 7c3af22
Showing 1 changed file with 20 additions and 2 deletions.
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() {
return mSetAllItemsForced;
}

public void setmSetAllItemsForced(Boolean mSetAllItemsForced) {
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 ?
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 ?
mContext.getResources().getDisplayMetrics().widthPixels
: mLayoutState.mAvailable;
}
Expand Down

0 comments on commit 7c3af22

Please sign in to comment.