Search in sources :

Example 1 with HotAdapter

use of com.codeest.geeknews.ui.zhihu.adapter.HotAdapter in project GeekNews by codeestX.

the class HotFragment method initEventAndData.

@Override
protected void initEventAndData() {
    mList = new ArrayList<>();
    ivProgress.start();
    mAdapter = new HotAdapter(mContext, mList);
    rvHotContent.setVisibility(View.INVISIBLE);
    rvHotContent.setLayoutManager(new LinearLayoutManager(mContext));
    rvHotContent.setAdapter(mAdapter);
    mPresenter.getHotData();
    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            mPresenter.getHotData();
        }
    });
    mAdapter.setOnItemClickListener(new HotAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(int position, View shareView) {
            mPresenter.insertReadToDB(mList.get(position).getNews_id());
            mAdapter.setReadState(position, true);
            mAdapter.notifyItemChanged(position);
            Intent intent = new Intent();
            intent.setClass(mContext, ZhihuDetailActivity.class);
            intent.putExtra("id", mList.get(position).getNews_id());
            ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(mActivity, shareView, "shareView");
            mContext.startActivity(intent, options.toBundle());
        }
    });
}
Also used : HotAdapter(com.codeest.geeknews.ui.zhihu.adapter.HotAdapter) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ProgressImageView(com.codeest.geeknews.widget.ProgressImageView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) ZhihuDetailActivity(com.codeest.geeknews.ui.zhihu.activity.ZhihuDetailActivity) ActivityOptions(android.app.ActivityOptions)

Aggregations

ActivityOptions (android.app.ActivityOptions)1 Intent (android.content.Intent)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 BindView (butterknife.BindView)1 ZhihuDetailActivity (com.codeest.geeknews.ui.zhihu.activity.ZhihuDetailActivity)1 HotAdapter (com.codeest.geeknews.ui.zhihu.adapter.HotAdapter)1 ProgressImageView (com.codeest.geeknews.widget.ProgressImageView)1