Skip to content

Instantly share code, notes, and snippets.

View DevAhamed's full-sized avatar

Riyaz Ahamed DevAhamed

View GitHub Profile
// NewsPaperSources
ListSection<NewsSource> newsPaperSources = new ListSection();
ItemSection<NewsSource> newsPaperNoneItem = new ItemSection(new NewsSource(NewsSource.NONE));
// Create a nested section for NewsPaperSources
NestedSection nestedNewsPaperSection = new NestedSection();
nestedNewsPaperSection.addSection(newsPaperSources);
nestedNewsPaperSection.addSection(newsPaperNoneItem);
// NewsChannelSources
// ItemBinder for NewsSource
public class NewsSourceBinder extends ItemBinder<NewsSource, NewsSourceBinder.ViewHolder> {
@Override public ViewHolder createViewHolder(ViewGroup parent) {
return new ViewHolder(inflate(parent, R.layout.item_news_source));
}
@Override public void bindViewHolder(ViewHolder holder, NewsSource item) {
holder.imageView.setImageResource(item.getIconResource());
holder.textView.setText(item.getText());
DividerItemDecoration decoration = new DividerItemDecoration(getApplicationContext(), VERTICAL);
recyclerView.addItemDecoration(decoration);
@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
canvas.save();
final int leftWithMargin = convertDpToPixel(56);
final int right = parent.getWidth();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
int adapterPosition = parent.getChildAdapterPosition(child);
@DevAhamed
DevAhamed / app-build.gradle
Last active June 7, 2017 10:50
Gist's for medium article
dependencies {
// ... other dependencies here
compile 'com.github.devahamed:multi-view-adapter:1.1.0'
}