use of cn.nicolite.palm300heroes.model.bean.Equipment 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);
}
}
});
}
use of cn.nicolite.palm300heroes.model.bean.Equipment in project Palm300Heroes by nicolite.
the class EquJJCPresenter method showEquJJCList.
public void showEquJJCList(boolean isForce) {
final EquipmentDao equipmentDao = getDaoSession().getEquipmentDao();
if (!isForce && equipmentDao.count() > 0) {
if (getView() != null) {
List<Equipment> equipmentList = equipmentDao.queryBuilder().where(EquipmentDao.Properties.Type.eq("JJC")).orderAsc(EquipmentDao.Properties.Id).list();
getView().showEquJJCList(equipmentList);
}
return;
}
if (getView() != null) {
getView().showLoading();
}
BmobQuery<Equipment> query = new BmobQuery<>(Constants.BMOB_EQUIPMENT);
query.addWhereEqualTo("type", "JJC").order("id").setLimit(300).findObjects(new FindListener<Equipment>() {
@Override
public void done(final List<Equipment> list, BmobException e) {
if (getView() != null) {
getView().closeLoading();
if (e == null) {
getView().showEquJJCList(list);
if (!saveFlag) {
saveFlag = true;
new Thread(new Runnable() {
@Override
public void run() {
List<Equipment> jjcList = equipmentDao.queryBuilder().where(EquipmentDao.Properties.Type.eq("JJC")).list();
for (Equipment equipment : jjcList) {
equipmentDao.delete(equipment);
}
for (Equipment equipment : list) {
equipmentDao.insert(equipment);
}
saveFlag = false;
}
}).start();
}
} else {
getView().loadFailure();
BmobUtils.showErrorMessage(e.toString());
}
}
}
});
}
Aggregations