Adds skills to monster cards.
This commit is contained in:
@@ -17,6 +17,7 @@ import com.majinnaibu.monstercards.R;
|
||||
import com.majinnaibu.monstercards.helpers.StringHelper;
|
||||
import com.majinnaibu.monstercards.models.Monster;
|
||||
import com.majinnaibu.monstercards.models.SavingThrow;
|
||||
import com.majinnaibu.monstercards.models.Skill;
|
||||
|
||||
@SuppressWarnings("FieldCanBeLocal")
|
||||
public class MonsterFragment extends Fragment {
|
||||
@@ -66,6 +67,9 @@ public class MonsterFragment extends Fragment {
|
||||
monster.addSavingThrow(new SavingThrow("int", 3));
|
||||
monster.addSavingThrow(new SavingThrow("wis", 4));
|
||||
monster.addSavingThrow(new SavingThrow("cha", 5));
|
||||
//Skills
|
||||
monster.addSkill(new Skill("perception", "wis"));
|
||||
monster.addSkill(new Skill("stealth", "dexterity"));
|
||||
|
||||
// Challenge Rating
|
||||
monster.setChallengeRating("*");
|
||||
@@ -177,6 +181,19 @@ public class MonsterFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
final TextView monsterSkills = root.findViewById(R.id.skills);
|
||||
monsterViewModel.getSkills().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(String skills) {
|
||||
if (StringHelper.isNullOrEmpty(skills)) {
|
||||
monsterSkills.setVisibility(View.GONE);
|
||||
} else {
|
||||
monsterSkills.setVisibility(View.VISIBLE);
|
||||
}
|
||||
monsterSkills.setText(Html.fromHtml("<b>Skills</b> " + skills));
|
||||
}
|
||||
});
|
||||
|
||||
return root;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ public class MonsterViewModel extends ViewModel {
|
||||
mCharisma.setValue("");
|
||||
mSavingThrows = new MutableLiveData<>();
|
||||
mSavingThrows.setValue("");
|
||||
mSkills = new MutableLiveData<>();
|
||||
mSkills.setValue("");
|
||||
}
|
||||
|
||||
private MutableLiveData<String> mName;
|
||||
@@ -84,6 +86,10 @@ public class MonsterViewModel extends ViewModel {
|
||||
public LiveData<String> getSavingThrows() {
|
||||
return mSavingThrows;
|
||||
}
|
||||
private MutableLiveData<String> mSkills;
|
||||
public LiveData<String> getSkills() {
|
||||
return mSkills;
|
||||
}
|
||||
|
||||
private Monster mMonster;
|
||||
public void setMonster(Monster monster) {
|
||||
@@ -100,5 +106,6 @@ public class MonsterViewModel extends ViewModel {
|
||||
mWisdom.setValue(monster.getWisdomDescription());
|
||||
mCharisma.setValue(monster.getCharismaDescription());
|
||||
mSavingThrows.setValue(monster.getSavingThrowsDescription());
|
||||
mSkills.setValue(monster.getSkillsDescription());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user