Search in sources :

Example 1 with HeroAdapter

use of cn.nicolite.palm300heroes.view.adapter.HeroAdapter in project Palm300Heroes by nicolite.

the class HeroListFragment method doBusiness.

@Override
protected void doBusiness() {
    heroListPresenter = new HeroListPresenter(this, this);
    // 根据屏幕宽度计算一行能放多少个
    int spanCount = (int) (ScreenUtils.getScreenWidth(context) / ScreenUtils.dp2px(context, 80));
    // 防止每行个数为0
    if (spanCount == 0) {
        spanCount = 4;
    }
    lRecyclerView.setLayoutManager(new GridLayoutManager(context, spanCount, OrientationHelper.VERTICAL, false));
    lRecyclerViewAdapter = new LRecyclerViewAdapter(new HeroAdapter(context, dataList));
    lRecyclerView.setAdapter(lRecyclerViewAdapter);
    lRecyclerView.setLoadMoreEnabled(false);
    lRecyclerView.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            heroListPresenter.showHeroList(true);
        }
    });
    lRecyclerView.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
        }
    });
    lRecyclerView.setOnNetWorkErrorListener(new OnNetWorkErrorListener() {

        @Override
        public void reload() {
        }
    });
    lRecyclerViewAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(View view, int position) {
            Hero hero = dataList.get(position);
            Bundle bundle = new Bundle();
            bundle.putString("heroName", hero.getHeroName());
            bundle.putString("heroType", hero.getHeroType());
            bundle.putString("heroUNCode", hero.getUNCode());
            bundle.putString("heroImage", hero.getPictureUrl());
            bundle.putString("heroBackground", hero.getBackground());
            bundle.putString("heroCoins", hero.getCoinsPrice());
            bundle.putString("heroDiamond", hero.getDiamondPrice());
            startActivity(HeroesDetailActivity.class, bundle);
        }
    });
    if (isFirstVisible && ListUtils.isEmpty(dataList)) {
        heroListPresenter.showHeroList(false);
    }
}
Also used : OnLoadMoreListener(com.github.jdsjlzx.interfaces.OnLoadMoreListener) OnNetWorkErrorListener(com.github.jdsjlzx.interfaces.OnNetWorkErrorListener) OnItemClickListener(com.github.jdsjlzx.interfaces.OnItemClickListener) Bundle(android.os.Bundle) HeroListPresenter(cn.nicolite.palm300heroes.presenter.HeroListPresenter) BindView(butterknife.BindView) IHeroListView(cn.nicolite.palm300heroes.view.iview.IHeroListView) LRecyclerView(com.github.jdsjlzx.recyclerview.LRecyclerView) View(android.view.View) LRecyclerViewAdapter(com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter) GridLayoutManager(android.support.v7.widget.GridLayoutManager) HeroesDetailActivity(cn.nicolite.palm300heroes.view.activity.HeroesDetailActivity) HeroAdapter(cn.nicolite.palm300heroes.view.adapter.HeroAdapter) Hero(cn.nicolite.palm300heroes.model.bean.Hero) OnRefreshListener(com.github.jdsjlzx.interfaces.OnRefreshListener)

Aggregations

Bundle (android.os.Bundle)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 View (android.view.View)1 BindView (butterknife.BindView)1 Hero (cn.nicolite.palm300heroes.model.bean.Hero)1 HeroListPresenter (cn.nicolite.palm300heroes.presenter.HeroListPresenter)1 HeroesDetailActivity (cn.nicolite.palm300heroes.view.activity.HeroesDetailActivity)1 HeroAdapter (cn.nicolite.palm300heroes.view.adapter.HeroAdapter)1 IHeroListView (cn.nicolite.palm300heroes.view.iview.IHeroListView)1 OnItemClickListener (com.github.jdsjlzx.interfaces.OnItemClickListener)1 OnLoadMoreListener (com.github.jdsjlzx.interfaces.OnLoadMoreListener)1 OnNetWorkErrorListener (com.github.jdsjlzx.interfaces.OnNetWorkErrorListener)1 OnRefreshListener (com.github.jdsjlzx.interfaces.OnRefreshListener)1 LRecyclerView (com.github.jdsjlzx.recyclerview.LRecyclerView)1 LRecyclerViewAdapter (com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter)1