Skip to content

Commit

Permalink
add click
Browse files Browse the repository at this point in the history
  • Loading branch information
ChadCym committed Apr 21, 2016
1 parent 4206f2e commit 6c6a8cf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,37 @@
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import android.widget.Toast;

import com.chad.baserecyclerviewadapterhelper.adapter.SectionAdapter;
import com.chad.baserecyclerviewadapterhelper.data.DataServer;
import com.chad.baserecyclerviewadapterhelper.decoration.GridItemDecoration;
import com.chad.baserecyclerviewadapterhelper.entity.MySection;
import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.List;

/**
* https://github.com/CymChad/BaseRecyclerViewAdapterHelper
*/
public class SectionUerActivity extends Activity {
public class SectionUerActivity extends Activity implements BaseQuickAdapter.OnRecyclerViewItemClickListener {
private RecyclerView mRecyclerView;
private List<MySection> mData;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_section_uer);
mRecyclerView = (RecyclerView) findViewById(R.id.rv_list);
mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
SectionAdapter sectionAdapter = new SectionAdapter(this, R.layout.head_view, R.layout.def_section_head, DataServer.getSampleData());
mData = DataServer.getSampleData();
SectionAdapter sectionAdapter = new SectionAdapter(this, R.layout.head_view, R.layout.def_section_head, mData);
sectionAdapter.setOnRecyclerViewItemClickListener(this);
mRecyclerView.addItemDecoration(new GridItemDecoration(this,R.drawable.list_divider));
mRecyclerView.setAdapter(sectionAdapter);
}

@Override
public void onItemClick(View view, int position) {
Toast.makeText(this,mData.get(position).t.name,Toast.LENGTH_LONG).show();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
/**
* https://github.com/CymChad/BaseRecyclerViewAdapterHelper
*/
public class MySection<Video> extends SectionEntity {
public class MySection extends SectionEntity<Video> {
public boolean isMroe;
public MySection(boolean isHeader, String header,boolean isMroe) {
public MySection(boolean isHeader, String header, boolean isMroe) {
super(isHeader, header);
this.isMroe = isMroe;
}

public MySection(Video t) {
super(t);
}
Expand Down

0 comments on commit 6c6a8cf

Please sign in to comment.