use of com.codeest.geeknews.ui.zhihu.adapter.ThemeChildAdapter in project GeekNews by codeestX.
the class ThemeActivity method initEventAndData.
@Override
protected void initEventAndData() {
Intent intent = getIntent();
id = intent.getExtras().getInt("id");
ivProgress.start();
mList = new ArrayList<>();
mAdapter = new ThemeChildAdapter(mContext, mList);
rvThemeChildList.setLayoutManager(new LinearLayoutManager(mContext));
rvThemeChildList.setAdapter(mAdapter);
mPresenter.getThemeChildData(id);
mAdapter.setOnItemClickListener(new ThemeChildAdapter.OnItemClickListener() {
@Override
public void onItemClick(int position, View shareView) {
mPresenter.insertReadToDB(mList.get(position).getId());
mAdapter.setReadState(position, true);
mAdapter.notifyItemChanged(position);
Intent intent = new Intent();
intent.setClass(mContext, ZhihuDetailActivity.class);
intent.putExtra("id", mList.get(position).getId());
if (shareView != null) {
mContext.startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(mContext, shareView, "shareView").toBundle());
} else {
startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(mContext).toBundle());
}
}
});
appbar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (verticalOffset >= 0) {
swipeRefresh.setEnabled(true);
} else {
swipeRefresh.setEnabled(false);
float rate = (float) (SystemUtil.dp2px(mContext, 256) + verticalOffset * 2) / SystemUtil.dp2px(mContext, 256);
if (rate >= 0)
ivOrigin.setAlpha(rate);
}
}
});
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mPresenter.getThemeChildData(id);
}
});
}
Aggregations