use of cn.nicolite.palm300heroes.presenter.HeroListPresenter 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);
}
}
Aggregations