当前位置: 首页>>代码示例>>Java>>正文


Java ItemViewBinder类代码示例

本文整理汇总了Java中me.drakeet.multitype.ItemViewBinder的典型用法代码示例。如果您正苦于以下问题:Java ItemViewBinder类的具体用法?Java ItemViewBinder怎么用?Java ItemViewBinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ItemViewBinder类属于me.drakeet.multitype包,在下文中一共展示了ItemViewBinder类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerNewsArticleItem

import me.drakeet.multitype.ItemViewBinder; //导入依赖的package包/类
public static void registerNewsArticleItem(@NonNull MultiTypeAdapter adapter) {
    // 一个类型对应多个 ItemViewBinder
    adapter.register(MultiNewsArticleDataBean.class)
            .to(new NewsArticleImgViewBinder(),
                    new NewsArticleVideoViewBinder(),
                    new NewsArticleTextViewBinder())
            .withClassLinker(new ClassLinker<MultiNewsArticleDataBean>() {
                @NonNull
                @Override
                public Class<? extends ItemViewBinder<MultiNewsArticleDataBean, ?>> index(int position, @NonNull MultiNewsArticleDataBean item) {
                    if (item.isHas_video()) {
                        return NewsArticleVideoViewBinder.class;
                    }
                    if (null != item.getImage_list() && item.getImage_list().size() > 0) {
                        return NewsArticleImgViewBinder.class;
                    }
                    return NewsArticleTextViewBinder.class;
                }
            });
    adapter.register(LoadingBean.class, new LoadingViewBinder());
    adapter.register(LoadingEndBean.class, new LoadingEndViewBinder());
}
 
开发者ID:iMeiji,项目名称:Toutiao,代码行数:23,代码来源:Register.java

示例2: registerWendaArticleItem

import me.drakeet.multitype.ItemViewBinder; //导入依赖的package包/类
public static void registerWendaArticleItem(@NonNull MultiTypeAdapter adapter) {
    // 一个类型对应多个 ItemViewBinder
    adapter.register(WendaArticleDataBean.class)
            .to(new WendaArticleTextViewBinder(),
                    new WendaArticleOneImgViewBinder(),
                    new WendaArticleThreeImgViewBinder())
            .withClassLinker(new ClassLinker<WendaArticleDataBean>() {
                @NonNull
                @Override
                public Class<? extends ItemViewBinder<WendaArticleDataBean, ?>> index(int position, @NonNull WendaArticleDataBean item) {
                    if (null != item.getExtraBean().getWenda_image() &&
                            null != item.getExtraBean().getWenda_image().getThree_image_list() &&
                            item.getExtraBean().getWenda_image().getThree_image_list().size() > 0) {
                        return WendaArticleThreeImgViewBinder.class;
                    }
                    if (null != item.getExtraBean().getWenda_image() &&
                            null != item.getExtraBean().getWenda_image().getLarge_image_list() &&
                            item.getExtraBean().getWenda_image().getLarge_image_list().size() > 0) {
                        return WendaArticleOneImgViewBinder.class;
                    }
                    return WendaArticleTextViewBinder.class;
                }
            });
    adapter.register(LoadingBean.class, new LoadingViewBinder());
    adapter.register(LoadingEndBean.class, new LoadingEndViewBinder());
}
 
开发者ID:iMeiji,项目名称:Toutiao,代码行数:27,代码来源:Register.java

示例3: registerSearchItem

import me.drakeet.multitype.ItemViewBinder; //导入依赖的package包/类
public static void registerSearchItem(@NonNull MultiTypeAdapter adapter) {
    adapter.register(MultiNewsArticleDataBean.class)
            .to(new NewsArticleImgViewBinder(),
                    new SearchArticleVideoViewBinder(),
                    new NewsArticleTextViewBinder())
            .withClassLinker(new ClassLinker<MultiNewsArticleDataBean>() {
                @NonNull
                @Override
                public Class<? extends ItemViewBinder<MultiNewsArticleDataBean, ?>> index(int position, @NonNull MultiNewsArticleDataBean item) {
                    if (item.isHas_video()) {
                        return SearchArticleVideoViewBinder.class;
                    }
                    if (null != item.getImage_list() && item.getImage_list().size() > 0) {
                        return NewsArticleImgViewBinder.class;
                    }
                    return NewsArticleTextViewBinder.class;
                }
            });
    adapter.register(LoadingBean.class, new LoadingViewBinder());
    adapter.register(LoadingEndBean.class, new LoadingEndViewBinder());
}
 
开发者ID:iMeiji,项目名称:Toutiao,代码行数:22,代码来源:Register.java

示例4: registerMediaArticleItem

import me.drakeet.multitype.ItemViewBinder; //导入依赖的package包/类
public static void registerMediaArticleItem(@NonNull MultiTypeAdapter adapter) {
    adapter.register(MultiMediaArticleBean.DataBean.class)
            .to(new MediaArticleImgViewBinder(),
                    new MediaArticleVideoViewBinder(),
                    new MediaArticleTextViewBinder())
            .withClassLinker(new ClassLinker<MultiMediaArticleBean.DataBean>() {
                @NonNull
                @Override
                public Class<? extends ItemViewBinder<MultiMediaArticleBean.DataBean, ?>> index(int position, @NonNull MultiMediaArticleBean.DataBean item) {
                    if (item.isHas_video()) {
                        return MediaArticleVideoViewBinder.class;
                    }
                    if (null != item.getImage_list() && item.getImage_list().size() > 0) {
                        return MediaArticleImgViewBinder.class;
                    }
                    return MediaArticleTextViewBinder.class;
                }
            });
    adapter.register(MediaProfileBean.DataBean.class, new MediaArticleHeaderViewBinder());
    adapter.register(LoadingBean.class, new LoadingViewBinder());
    adapter.register(LoadingEndBean.class, new LoadingEndViewBinder());
}
 
开发者ID:iMeiji,项目名称:Toutiao,代码行数:23,代码来源:Register.java

示例5: initRecyclerView

import me.drakeet.multitype.ItemViewBinder; //导入依赖的package包/类
private void initRecyclerView(int flag) {
    mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    mAdapter = new MultiTypeAdapter();
    mAdapter.register(Banner.class)
            .to(new BannerBinder(this), new SquareCardBinder(this))
            .withClassLinker(new ClassLinker<Banner>() {
                @NonNull
                @Override
                public Class<? extends ItemViewBinder<Banner, ?>> index(@NonNull Banner banner) {
                    if (banner.type == FLAG_ALL_CATEGORY) {
                        return SquareCardBinder.class;
                    } else {
                        return BannerBinder.class;
                    }
                }
            });
    mAdapter.register(EndArea.class, new EndAreaBinder(EndAreaBinder.FLAG_TEXT_COLOR_BLACK));
    mAdapter.register(LeftAlignTextHeader.class, new LeftAlignTextHeaderBinder());
    mAdapter.register(AuthorCard.class, new AuthorCardBinder(this));
    mAdapter.register(AuthorCollectionItem.class, new AuthorCollectionItemBinder(this));

    mItems = new Items();
    mAdapter.setItems(mItems);
    if (flag == FLAG_ALL_CATEGORY) {
        GridLayoutManager manager = new GridLayoutManager(this, 2);
        manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                return (mItems.get(position) instanceof EndArea) ? 2 : 1;
            }
        });
        mRecyclerView.setLayoutManager(manager);
    } else {
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    }
    mRecyclerView.setAdapter(mAdapter);
}
 
开发者ID:KnowledgeBegger,项目名称:MyEyepetizer,代码行数:38,代码来源:RecyclerViewActivity.java

示例6: registerMultiType

import me.drakeet.multitype.ItemViewBinder; //导入依赖的package包/类
private void registerMultiType(@NonNull final MessageAdapter adapter) {
    adapter.register(Message.class)
        .to(new TextMessageViewBinder())
        .withClassLinker(new ClassLinker<Message>() {
            @NonNull @Override @SuppressWarnings("unchecked")
            public Class<? extends ItemViewBinder<Message, ?>> index(@NonNull Message message) {
                if (message.content.getClass() == TextContent.class) {
                    return TextMessageViewBinder.class;
                }
                return TextMessageViewBinder.class;
            }
        });
}
 
开发者ID:drakeet,项目名称:TimeMachine,代码行数:14,代码来源:CoreFragment.java


注:本文中的me.drakeet.multitype.ItemViewBinder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。