use of cn.nicolite.palm300heroes.model.bean.Talent in project Palm300Heroes by nicolite.
the class UpdateDataModel method updateTalent.
public static void updateTalent() {
BmobQuery<Talent> query = new BmobQuery<>(Constants.BMOB_TALENT);
query.setLimit(45).order("position").findObjects(new FindListener<Talent>() {
@Override
public void done(final List<Talent> list, BmobException e) {
if (e == null) {
new Thread(new Runnable() {
@Override
public void run() {
TalentDao talentDao = daoSession.getTalentDao();
talentDao.deleteAll();
for (Talent talent : list) {
talentDao.insert(talent);
}
progress.incrementAndGet();
}
});
}
}
});
}
use of cn.nicolite.palm300heroes.model.bean.Talent in project Palm300Heroes by nicolite.
the class TalentActivity method showTalentList.
@Override
public void showTalentList(List<Talent> talentList) {
Talent talent = new Talent();
talent.setType("T");
talent.setName("功能专精");
talentList.add(0, talent);
talent = new Talent();
talent.setType("T");
talent.setName("");
talentList.add(1, talent);
talentList.add(2, talent);
talent = new Talent();
talent.setType("T");
talent.setName("攻击专精");
talentList.add(18, talent);
talent = new Talent();
talent.setType("T");
talent.setName("");
talentList.add(19, talent);
talentList.add(20, talent);
talent = new Talent();
talent.setType("T");
talent.setName("防御专精");
talentList.add(36, talent);
talent = new Talent();
talent.setType("T");
talent.setName("");
talentList.add(37, talent);
talentList.add(38, talent);
dataList.clear();
dataList.addAll(talentList);
lRecyclerView.refreshComplete(talentList.size());
lRecyclerViewAdapter.notifyDataSetChanged();
}
use of cn.nicolite.palm300heroes.model.bean.Talent in project Palm300Heroes by nicolite.
the class TalentActivity method doBusiness.
@Override
protected void doBusiness() {
toolbarTitle.setText("天赋技能");
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
}
lRecyclerView.setLayoutManager(new GridLayoutManager(context, 3, OrientationHelper.VERTICAL, false));
lRecyclerViewAdapter = new LRecyclerViewAdapter(new TalentAdapter(context, dataList));
lRecyclerView.setAdapter(lRecyclerViewAdapter);
lRecyclerView.setLoadMoreEnabled(false);
talentPresenter = new TalentPresenter(this, this);
lRecyclerView.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
talentPresenter.showTalent(true);
}
});
lRecyclerView.setOnNetWorkErrorListener(new OnNetWorkErrorListener() {
@Override
public void reload() {
talentPresenter.showTalent(true);
}
});
lRecyclerViewAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Talent talent = dataList.get(position);
Bundle bundle = new Bundle();
bundle.putString("picture", talent.getPicture());
bundle.putString("name", talent.getName());
bundle.putString("recommend", talent.getRecommend());
bundle.putString("belongTo", talent.getBelongTo());
bundle.putString("skill", talent.getSkill());
bundle.putString("level", String.valueOf(talent.getLevel()));
startActivity(TalentDetailActivity.class, bundle);
}
});
talentPresenter.showTalent(false);
}
use of cn.nicolite.palm300heroes.model.bean.Talent in project Palm300Heroes by nicolite.
the class TalentAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
Talent talent = dataList.get(position);
if (holder instanceof TalentViewHolder) {
TalentViewHolder talentViewHolder = (TalentViewHolder) holder;
Glide.with(context).load(Constants.TALENT_URL + Uri.encode(talent.getPicture())).crossFade().error(R.drawable.img_error).into(talentViewHolder.itemImg);
talentViewHolder.itemText.setText(talent.getName());
} else if (holder instanceof TextVieWHolder) {
TextVieWHolder textViewHolder = (TextVieWHolder) holder;
textViewHolder.text.setText(talent.getName());
}
}
use of cn.nicolite.palm300heroes.model.bean.Talent in project Palm300Heroes by nicolite.
the class TalentPresenter method showTalent.
public void showTalent(boolean isForce) {
final TalentDao talentDao = getDaoSession().getTalentDao();
if (!isForce && talentDao.count() > 0) {
if (getView() != null) {
List<Talent> list = talentDao.queryBuilder().orderAsc(TalentDao.Properties.Position).list();
getView().showTalentList(list);
}
return;
}
if (getView() != null) {
getView().showLoading();
}
BmobQuery<Talent> query = new BmobQuery<>(Constants.BMOB_TALENT);
query.setLimit(45).order("position").findObjects(new FindListener<Talent>() {
@Override
public void done(final List<Talent> list, BmobException e) {
if (getView() != null) {
getView().closeLoading();
if (e == null) {
getView().showTalentList(list);
if (!saveFlag) {
saveFlag = true;
new Thread(new Runnable() {
@Override
public void run() {
for (Talent talent : list) {
talentDao.insert(talent);
}
saveFlag = false;
}
});
}
} else {
BmobUtils.showErrorMessage(e.toString());
}
}
}
});
}
Aggregations