Search in sources :

Example 1 with Talent

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();
                    }
                });
            }
        }
    });
}
Also used : BmobException(cn.bmob.v3.exception.BmobException) TalentDao(cn.nicolite.palm300heroes.db.dao.TalentDao) BmobQuery(cn.bmob.v3.BmobQuery) Talent(cn.nicolite.palm300heroes.model.bean.Talent)

Example 2 with Talent

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();
}
Also used : Talent(cn.nicolite.palm300heroes.model.bean.Talent)

Example 3 with Talent

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);
}
Also used : OnNetWorkErrorListener(com.github.jdsjlzx.interfaces.OnNetWorkErrorListener) OnItemClickListener(com.github.jdsjlzx.interfaces.OnItemClickListener) Bundle(android.os.Bundle) Talent(cn.nicolite.palm300heroes.model.bean.Talent) ITalentView(cn.nicolite.palm300heroes.view.iview.ITalentView) BindView(butterknife.BindView) TextView(android.widget.TextView) LRecyclerView(com.github.jdsjlzx.recyclerview.LRecyclerView) View(android.view.View) LRecyclerViewAdapter(com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter) TalentPresenter(cn.nicolite.palm300heroes.presenter.TalentPresenter) GridLayoutManager(android.support.v7.widget.GridLayoutManager) TalentAdapter(cn.nicolite.palm300heroes.view.adapter.TalentAdapter) ActionBar(android.support.v7.app.ActionBar) OnRefreshListener(com.github.jdsjlzx.interfaces.OnRefreshListener)

Example 4 with Talent

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());
    }
}
Also used : Talent(cn.nicolite.palm300heroes.model.bean.Talent)

Example 5 with Talent

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());
                }
            }
        }
    });
}
Also used : TalentDao(cn.nicolite.palm300heroes.db.dao.TalentDao) BmobException(cn.bmob.v3.exception.BmobException) BmobQuery(cn.bmob.v3.BmobQuery) Talent(cn.nicolite.palm300heroes.model.bean.Talent)

Aggregations

Talent (cn.nicolite.palm300heroes.model.bean.Talent)5 BmobQuery (cn.bmob.v3.BmobQuery)2 BmobException (cn.bmob.v3.exception.BmobException)2 TalentDao (cn.nicolite.palm300heroes.db.dao.TalentDao)2 Bundle (android.os.Bundle)1 ActionBar (android.support.v7.app.ActionBar)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 View (android.view.View)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 TalentPresenter (cn.nicolite.palm300heroes.presenter.TalentPresenter)1 TalentAdapter (cn.nicolite.palm300heroes.view.adapter.TalentAdapter)1 ITalentView (cn.nicolite.palm300heroes.view.iview.ITalentView)1 OnItemClickListener (com.github.jdsjlzx.interfaces.OnItemClickListener)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