mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-19 12:18:59 +00:00
fix user NPE on SkillsFragment
This commit is contained in:
parent
2d645bff40
commit
4d7f4a681c
1 changed files with 16 additions and 3 deletions
|
|
@ -18,6 +18,7 @@ import com.habitrpg.android.habitica.callbacks.SkillCallback;
|
|||
import com.habitrpg.android.habitica.events.SkillUsedEvent;
|
||||
import com.habitrpg.android.habitica.events.commands.UseSkillCommand;
|
||||
import com.habitrpg.android.habitica.ui.adapter.SkillsRecyclerViewAdapter;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Skill;
|
||||
import com.raizlabs.android.dbflow.sql.builder.Condition;
|
||||
import com.raizlabs.android.dbflow.sql.language.Select;
|
||||
|
|
@ -47,8 +48,7 @@ public class SkillsFragment extends BaseFragment {
|
|||
view = inflater.inflate(R.layout.fragment_skills, container, false);
|
||||
|
||||
adapter = new SkillsRecyclerViewAdapter();
|
||||
adapter.mana = this.user.getStats().getMp();
|
||||
loadSkills();
|
||||
checkUserLoadSkills();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
|
@ -68,7 +68,13 @@ public class SkillsFragment extends BaseFragment {
|
|||
mRecyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
public void loadSkills() {
|
||||
private void checkUserLoadSkills(){
|
||||
if(user == null || adapter == null){
|
||||
return;
|
||||
}
|
||||
|
||||
adapter.mana = this.user.getStats().getMp();
|
||||
|
||||
List<Skill> skills = new Select()
|
||||
.from(Skill.class)
|
||||
.where(Condition.column("habitClass").eq(user.getStats().get_class()))
|
||||
|
|
@ -77,6 +83,13 @@ public class SkillsFragment extends BaseFragment {
|
|||
adapter.setSkillList(skills);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUser(HabitRPGUser user) {
|
||||
super.setUser(user);
|
||||
|
||||
checkUserLoadSkills();
|
||||
}
|
||||
|
||||
public void onEvent(UseSkillCommand command) {
|
||||
Skill skill = command.skill;
|
||||
if (skill.target.equals("task")) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue