Hi , Thanks for the awesome library.
I'm using this library for creating expandable recyclerview. I've used this library before and it worked pretty well.But this time I couldn't get it to inflate, and i couldn't find the problem.As far as I know ,nothing happens after I set the adapter for the recyclerview.You can find my code below.
setting the group and child objects with Ids.
List<ChannelCategories> channelCategories = new ArrayList<>();
for (int k = 0; k < channelCats.length(); k++) {
List<Channels> channelsList = new ArrayList<>();
for (int p = 0; p < array.length(); p++) {
String channelId = thatChannelCatId.getString(p);
String dth_channel_name = channelDetails.getString(channelId);
channelsList.add(new Channels(p, dth_channel_name, dth_channel_cat_id));
}
channelCategories.add(new ChannelCategories(k, dth_channel_cat_name, channelsList));
}
Setting the adapter.
channelRecycler.setAdapter(new ChannelCategoriesAdapter(channelCategories));
Adapter
public class ChannelCategoriesAdapter extends AbstractExpandableItemAdapter<ChannelCategoriesAdapter.GroupViewH, ChannelCategoriesAdapter.ChildViewH> {
private List<ChannelCategories> channelCategories;
static class GroupViewH extends AbstractExpandableItemViewHolder {
@BindView(R.id.channelArrow)
AppCompatImageView channelArrow;
@BindView(R.id.catTitle)
TextView catTitle;
GroupViewH(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
}
static class ChildViewH extends AbstractExpandableItemViewHolder {
@BindView(R.id.channelName)
TextView channelName;
ChildViewH(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
}
public ChannelCategoriesAdapter(List<ChannelCategories> channelCategories) {
this.channelCategories = channelCategories;
setHasStableIds(true);
}
@Override
public GroupViewH onCreateGroupViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.dth_package_channel_group, parent, false);
return new GroupViewH(view);
}
@Override
public ChildViewH onCreateChildViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.dth_package_channel_child, parent, false);
return new ChildViewH(view);
}
@Override
public void onBindGroupViewHolder(GroupViewH holder, int groupPosition, int viewType) {
holder.catTitle.setText(String.format("%s,(%s)", channelCategories.get(groupPosition).getDthChannelCatName()
, channelCategories.get(groupPosition).getChannelsList().size()));
}
@Override
public void onBindChildViewHolder(ChildViewH holder, int groupPosition, int childPosition, int viewType) {
holder.channelName.setText(channelCategories.get(groupPosition).getChannelsList().get(childPosition).getChannelName());
}
@Override
public boolean onCheckCanExpandOrCollapseGroup(GroupViewH holder, int groupPosition, int x, int y, boolean expand) {
if (expand) {
holder.channelArrow.setImageDrawable(ContextCompat.getDrawable(holder.channelArrow.getContext(), R.drawable.ic_up_arrow_new_gray));
} else {
holder.channelArrow.setImageDrawable(ContextCompat.getDrawable(holder.channelArrow.getContext(), R.drawable.ic_arrow_down_gray));
}
return channelCategories.get(groupPosition).getChannelsList().size() > 0;
}
@Override
public int getGroupCount() {
return channelCategories.size();
}
@Override
public int getChildCount(int groupPosition) {
return channelCategories.get(groupPosition).getChannelsList().size();
}
@Override
public long getGroupId(int groupPosition) {
return channelCategories.get(groupPosition).getId();
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return channelCategories.get(groupPosition).getChannelsList().get(childPosition).getId();
}
}
Hi , Thanks for the awesome library. I'm using this library for creating expandable recyclerview. I've used this library before and it worked pretty well.But this time I couldn't get it to inflate, and i couldn't find the problem.As far as I know ,nothing happens after I set the adapter for the recyclerview.You can find my code below.
setting the group and child objects with Ids.
Setting the adapter.
channelRecycler.setAdapter(new ChannelCategoriesAdapter(channelCategories));
Adapter
Xml