Skip to content

Commit

Permalink
set LayoutManager
Browse files Browse the repository at this point in the history
  • Loading branch information
SlaVcE14 committed Feb 21, 2023
1 parent ea69769 commit e7d97ad
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ public class ListDialog extends SJDialog{
RecyclerView listRV;
boolean isSelectableList = false;
boolean hideEmptyListTxt = false;
boolean waitForLayoutManager = false;

private @DrawableRes int listItemBgRes = R.drawable.ripple_list;
private @DrawableRes int listItemBgResSelected = R.drawable.ripple_list_selected;
private int listItemTextColor = 1;
private RecyclerView.LayoutManager layoutManager = null;

RecyclerView.Adapter<?> adapter;
ArrayList<?> selectedItems = new ArrayList<>();
Expand Down Expand Up @@ -254,7 +256,11 @@ public ListDialog onButtonClick(DialogButtonEvents dialogButtonEvents) {

@Override
public ListDialog show() {
listRV.setLayoutManager(new LinearLayoutManager(context));
if (layoutManager == null)
layoutManager = new LinearLayoutManager(context);
if (!waitForLayoutManager)
listRV.setLayoutManager(layoutManager);

listRV.setAdapter(adapter);
if (adapter == null)
checkListsSize(0);
Expand Down Expand Up @@ -572,6 +578,11 @@ public ListDialog setAdapter(RecyclerView.Adapter<?> adapter){
return this;
}

public ListDialog setLayoutManager(RecyclerView.LayoutManager layoutManager) {
this.layoutManager = layoutManager;
return this;
}

/**
* Get a list adapter
* @return current class
Expand Down

0 comments on commit e7d97ad

Please sign in to comment.