Search in sources :

Example 1 with GankAdapter

use of com.xxx.ency.view.gank.adapter.GankAdapter in project Ency by xiarunhao123.

the class GankFragment method initialize.

@Override
protected void initialize() {
    Bundle args = getArguments();
    if (args != null) {
        type = args.getString("type");
    }
    swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
    swipeRefreshLayout.setRefreshing(true);
    swipeRefreshLayout.setOnRefreshListener(this);
    mPresenter.getGankData(type, PAGE_SIZE, page);
    mPresenter.getPTP();
    gankAdapter = new GankAdapter(resultsBeans);
    recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
    recyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL));
    recyclerView.setAdapter(gankAdapter);
    gankAdapter.setPTP(sharePrefManager.getProvincialTrafficPattern());
    gankAdapter.setOnLoadMoreListener(this, recyclerView);
    gankAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
            GankBean.ResultsBean bean = (GankBean.ResultsBean) adapter.getData().get(position);
            WebActivity.open(new WebActivity.Builder().setGuid(// 微信Item没有id,使用url作为guid
            bean.get_id()).setImgUrl("").setType(Constants.TYPE_GANK).setUrl(bean.getUrl()).setTitle(bean.getDesc()).setShowLikeIcon(true).setContext(mContext));
        }
    });
}
Also used : Bundle(android.os.Bundle) WebActivity(com.xxx.ency.view.web.WebActivity) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) GankBean(com.xxx.ency.model.bean.GankBean) GankAdapter(com.xxx.ency.view.gank.adapter.GankAdapter) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter)

Aggregations

Bundle (android.os.Bundle)1 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 BindView (butterknife.BindView)1 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)1 GankBean (com.xxx.ency.model.bean.GankBean)1 GankAdapter (com.xxx.ency.view.gank.adapter.GankAdapter)1 WebActivity (com.xxx.ency.view.web.WebActivity)1