Search in sources :

Example 1 with FightSkill

use of cn.nicolite.palm300heroes.model.bean.FightSkill in project Palm300Heroes by nicolite.

the class FightSkillAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final FightSkillViewHolder holder, int position) {
    FightSkill fightSkill = dataList.get(position);
    Glide.with(context).load(Constants.FIGHT_SKILL_URL + Uri.encode(fightSkill.getPicture())).crossFade().into(holder.img);
    holder.name.setText(fightSkill.getName());
    holder.level.setText(String.valueOf("召唤师等级:" + fightSkill.getLevel()));
    holder.cd.setText(String.valueOf("冷却时间:" + fightSkill.getCd()));
    holder.jjcEf.setText(String.valueOf(fightSkill.getJjc()));
    if (!TextUtils.isEmpty(fightSkill.getZc())) {
        holder.zcEf.setVisibility(View.VISIBLE);
        holder.zcEf.setText(String.valueOf(fightSkill.getZc()));
    } else {
        holder.zcEf.setVisibility(View.GONE);
    }
}
Also used : FightSkill(cn.nicolite.palm300heroes.model.bean.FightSkill)

Example 2 with FightSkill

use of cn.nicolite.palm300heroes.model.bean.FightSkill in project Palm300Heroes by nicolite.

the class FightSkillPresenter method showFightSkill.

public void showFightSkill(boolean isForce) {
    final FightSkillDao fightSkillDao = getDaoSession().getFightSkillDao();
    if (!isForce && fightSkillDao.count() > 0) {
        if (getView() != null) {
            List<FightSkill> list = fightSkillDao.queryBuilder().orderAsc(FightSkillDao.Properties.Position).list();
            getView().showFightSkill(list);
        }
        return;
    }
    if (getView() != null) {
        getView().showLoading();
    }
    BmobQuery<FightSkill> query = new BmobQuery<>(Constants.BMOB_FIGHT_SKILL);
    query.setLimit(20).order("position").findObjects(new FindListener<FightSkill>() {

        @Override
        public void done(final List<FightSkill> list, BmobException e) {
            if (getView() != null) {
                getView().closeLoading();
                if (e == null) {
                    getView().showFightSkill(list);
                    if (!saveFlag) {
                        saveFlag = true;
                        new Thread(new Runnable() {

                            @Override
                            public void run() {
                                fightSkillDao.deleteAll();
                                for (FightSkill fightSkill : list) {
                                    fightSkillDao.insert(fightSkill);
                                }
                                saveFlag = false;
                            }
                        }).start();
                    }
                } else {
                    BmobUtils.showErrorMessage(e.toString());
                }
            }
        }
    });
}
Also used : BmobException(cn.bmob.v3.exception.BmobException) BmobQuery(cn.bmob.v3.BmobQuery) FightSkillDao(cn.nicolite.palm300heroes.db.dao.FightSkillDao) FightSkill(cn.nicolite.palm300heroes.model.bean.FightSkill)

Aggregations

FightSkill (cn.nicolite.palm300heroes.model.bean.FightSkill)2 BmobQuery (cn.bmob.v3.BmobQuery)1 BmobException (cn.bmob.v3.exception.BmobException)1 FightSkillDao (cn.nicolite.palm300heroes.db.dao.FightSkillDao)1