use of me.yokeyword.sample.demo_wechat.adapter.PagerAdapter in project Fragmentation by YoKeyword.
the class FirstPagerFragment method initView.
private void initView(View view) {
EventBus.getDefault().register(this);
mRecy = (RecyclerView) view.findViewById(R.id.recy);
mRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
mRefreshLayout.setOnRefreshListener(this);
mAdapter = new PagerAdapter(_mActivity);
mRecy.setHasFixedSize(true);
LinearLayoutManager manager = new LinearLayoutManager(_mActivity);
mRecy.setLayoutManager(manager);
mRecy.setAdapter(mAdapter);
mRecy.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
mScrollTotal += dy;
if (mScrollTotal <= 0) {
mInAtTop = true;
} else {
mInAtTop = false;
}
}
});
mAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(int position, View view, RecyclerView.ViewHolder holder) {
// 通知MainActivity跳转至CycleFragment
EventBus.getDefault().post(new StartBrotherEvent(CycleFragment.newInstance(1)));
}
});
// Init Datas
List<String> items = new ArrayList<>();
for (int i = 0; i < 20; i++) {
String item = "联系人 " + i;
items.add(item);
}
mAdapter.setDatas(items);
}
Aggregations