Search in sources :

Example 1 with MySection

use of com.chad.baserecyclerviewadapterhelper.entity.MySection in project BaseRecyclerViewAdapterHelper by CymChad.

the class DataServer method getSampleData.

public static List<MySection> getSampleData() {
    List<MySection> list = new ArrayList<>();
    list.add(new MySection(true, "Section 1", true));
    list.add(new MySection(new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
    list.add(new MySection(new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
    list.add(new MySection(new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
    list.add(new MySection(new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
    list.add(new MySection(true, "Section 2", false));
    list.add(new MySection(new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
    list.add(new MySection(new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
    list.add(new MySection(new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
    list.add(new MySection(true, "Section 3", false));
    list.add(new MySection(new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
    list.add(new MySection(new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
    list.add(new MySection(true, "Section 4", false));
    list.add(new MySection(new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
    list.add(new MySection(new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
    list.add(new MySection(true, "Section 5", false));
    list.add(new MySection(new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
    list.add(new MySection(new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
    return list;
}
Also used : MySection(com.chad.baserecyclerviewadapterhelper.entity.MySection) Video(com.chad.baserecyclerviewadapterhelper.entity.Video) ArrayList(java.util.ArrayList)

Example 2 with MySection

use of com.chad.baserecyclerviewadapterhelper.entity.MySection in project BaseRecyclerViewAdapterHelper by CymChad.

the class SectionUseActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_section_uer);
    setBackBtn();
    setTitle("Section Use");
    mRecyclerView = (RecyclerView) findViewById(R.id.rv_list);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    mData = DataServer.getSampleData();
    SectionAdapter sectionAdapter = new SectionAdapter(R.layout.item_section_content, R.layout.def_section_head, mData);
    mRecyclerView.addOnItemTouchListener(new OnItemClickListener() {

        @Override
        public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
            MySection mySection = mData.get(position);
            if (mySection.isHeader)
                Toast.makeText(SectionUseActivity.this, mySection.header, Toast.LENGTH_LONG).show();
            else
                Toast.makeText(SectionUseActivity.this, mySection.t.getName(), Toast.LENGTH_LONG).show();
        }

        @Override
        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
            Toast.makeText(SectionUseActivity.this, "onItemChildClick" + position, Toast.LENGTH_LONG).show();
        }
    });
    mRecyclerView.setAdapter(sectionAdapter);
}
Also used : MySection(com.chad.baserecyclerviewadapterhelper.entity.MySection) OnItemClickListener(com.chad.library.adapter.base.listener.OnItemClickListener) SectionAdapter(com.chad.baserecyclerviewadapterhelper.adapter.SectionAdapter) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

MySection (com.chad.baserecyclerviewadapterhelper.entity.MySection)2 RecyclerView (android.support.v7.widget.RecyclerView)1 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 View (android.view.View)1 SectionAdapter (com.chad.baserecyclerviewadapterhelper.adapter.SectionAdapter)1 Video (com.chad.baserecyclerviewadapterhelper.entity.Video)1 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)1 OnItemClickListener (com.chad.library.adapter.base.listener.OnItemClickListener)1 ArrayList (java.util.ArrayList)1