Search in sources :

Example 1 with EquJJCPresenter

use of cn.nicolite.palm300heroes.presenter.EquJJCPresenter in project Palm300Heroes by nicolite.

the class EquJJCFragment method doBusiness.

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

        @Override
        public void onRefresh() {
            equJJCPresenter.showEquJJCList(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) {
            Equipment equipment = dataList.get(position);
            String purchasePrice = equipment.getPurchasePrice() == null ? "" : String.valueOf(equipment.getPurchasePrice());
            String compoundPrice = equipment.getCompoundPrice() == null ? "无法合成" : String.valueOf(equipment.getCompoundPrice());
            String attribute = TextUtils.isEmpty(equipment.getAttribute()) ? "无" : equipment.getAttribute();
            String skill = TextUtils.isEmpty(equipment.getSkill()) ? "无" : equipment.getSkill();
            Bundle bundle = new Bundle();
            bundle.putString("picture", equipment.getPicture());
            bundle.putString("name", equipment.getName());
            bundle.putString("pp", purchasePrice);
            bundle.putString("cp", compoundPrice);
            bundle.putString("attribute", attribute);
            bundle.putString("skill", skill);
            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
                startActivity(EquJJCDetailActivity.class, bundle);
            } else {
                Bundle options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, view, "equJJCTransition").toBundle();
                startActivity(EquJJCDetailActivity.class, bundle, options);
            }
        }
    });
}
Also used : OnLoadMoreListener(com.github.jdsjlzx.interfaces.OnLoadMoreListener) OnNetWorkErrorListener(com.github.jdsjlzx.interfaces.OnNetWorkErrorListener) OnItemClickListener(com.github.jdsjlzx.interfaces.OnItemClickListener) Bundle(android.os.Bundle) EquipmentJJCAdapter(cn.nicolite.palm300heroes.view.oldAdapter.EquipmentJJCAdapter) BindView(butterknife.BindView) LRecyclerView(com.github.jdsjlzx.recyclerview.LRecyclerView) View(android.view.View) IEquJJCView(cn.nicolite.palm300heroes.view.iview.IEquJJCView) EquJJCDetailActivity(cn.nicolite.palm300heroes.view.activity.EquJJCDetailActivity) LRecyclerViewAdapter(com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter) GridLayoutManager(android.support.v7.widget.GridLayoutManager) Equipment(cn.nicolite.palm300heroes.model.bean.Equipment) EquJJCPresenter(cn.nicolite.palm300heroes.presenter.EquJJCPresenter) 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 Equipment (cn.nicolite.palm300heroes.model.bean.Equipment)1 EquJJCPresenter (cn.nicolite.palm300heroes.presenter.EquJJCPresenter)1 EquJJCDetailActivity (cn.nicolite.palm300heroes.view.activity.EquJJCDetailActivity)1 IEquJJCView (cn.nicolite.palm300heroes.view.iview.IEquJJCView)1 EquipmentJJCAdapter (cn.nicolite.palm300heroes.view.oldAdapter.EquipmentJJCAdapter)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