use of me.yokeyword.sample.demo_wechat.adapter.HomeAdapter in project Fragmentation by YoKeyword.
the class WechatThirdTabFragment method onLazyInitView.
@Override
public void onLazyInitView(@Nullable Bundle savedInstanceState) {
super.onLazyInitView(savedInstanceState);
mAdapter = new HomeAdapter(_mActivity);
LinearLayoutManager manager = new LinearLayoutManager(_mActivity);
mRecy.setLayoutManager(manager);
mRecy.setAdapter(mAdapter);
mAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(int position, View view, RecyclerView.ViewHolder vh) {
// 通知MainActivity跳转至DetailFragment
EventBus.getDefault().post(new StartBrotherEvent(DetailFragment.newInstance(mAdapter.getItem(position).getTitle())));
}
});
// Init Datas
List<Article> articleList = new ArrayList<>();
for (int i = 0; i < 3; i++) {
Article article = new Article(mTitles[i], mContents[i]);
articleList.add(article);
}
mAdapter.setDatas(articleList);
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) {
mAtTop = true;
} else {
mAtTop = false;
}
}
});
}
Aggregations