use of com.codeest.geeknews.ui.zhihu.adapter.DailyAdapter in project GeekNews by codeestX.
the class DailyFragment method initEventAndData.
@Override
protected void initEventAndData() {
super.initEventAndData();
currentDate = DateUtil.getTomorrowDate();
mAdapter = new DailyAdapter(mContext, mList);
mAdapter.setOnItemClickListener(new DailyAdapter.OnItemClickListener() {
@Override
public void onItemClick(int position, View shareView) {
mPresenter.insertReadToDB(mList.get(position).getId());
mAdapter.setReadState(position, true);
if (mAdapter.getIsBefore()) {
mAdapter.notifyItemChanged(position + 1);
} else {
mAdapter.notifyItemChanged(position + 2);
}
Intent intent = new Intent();
intent.setClass(mContext, ZhihuDetailActivity.class);
intent.putExtra(Constants.IT_ZHIHU_DETAIL_ID, mList.get(position).getId());
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(mActivity, shareView, "shareView");
mContext.startActivity(intent, options.toBundle());
}
});
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (currentDate.equals(DateUtil.getTomorrowDate())) {
mPresenter.getDailyData();
} else {
int year = Integer.valueOf(currentDate.substring(0, 4));
int month = Integer.valueOf(currentDate.substring(4, 6));
int day = Integer.valueOf(currentDate.substring(6, 8));
CalendarDay date = CalendarDay.from(year, month - 1, day);
RxBus.getDefault().post(date);
}
}
});
rvDailyList.setLayoutManager(new LinearLayoutManager(mContext));
rvDailyList.setAdapter(mAdapter);
stateLoading();
mPresenter.getDailyData();
}
Aggregations