forked from github/wulkanowy-mirror
User short grade names in grades summary (#141)
This commit is contained in:
parent
dab1bd4ac6
commit
8725640168
@ -113,9 +113,9 @@ public class GradesHeader
|
|||||||
averageText.setText(getGradesAverageString());
|
averageText.setText(getGradesAverageString());
|
||||||
|
|
||||||
predictedText.setText(resources.getString(R.string.info_grades_predicted_rating,
|
predictedText.setText(resources.getString(R.string.info_grades_predicted_rating,
|
||||||
item.getPredictedRating()));
|
GradeUtils.getShortGradeValue(item.getPredictedRating())));
|
||||||
finalText.setText(resources.getString(R.string.info_grades_final_rating,
|
finalText.setText(resources.getString(R.string.info_grades_final_rating,
|
||||||
item.getFinalRating()));
|
GradeUtils.getShortGradeValue(item.getFinalRating())));
|
||||||
|
|
||||||
resetViews();
|
resetViews();
|
||||||
toggleSubjectText();
|
toggleSubjectText();
|
||||||
|
@ -16,6 +16,7 @@ import eu.davidea.flexibleadapter.items.IFlexible;
|
|||||||
import eu.davidea.viewholders.FlexibleViewHolder;
|
import eu.davidea.viewholders.FlexibleViewHolder;
|
||||||
import io.github.wulkanowy.R;
|
import io.github.wulkanowy.R;
|
||||||
import io.github.wulkanowy.data.db.dao.entities.Subject;
|
import io.github.wulkanowy.data.db.dao.entities.Subject;
|
||||||
|
import io.github.wulkanowy.utils.GradeUtils;
|
||||||
|
|
||||||
public class GradesSummarySubItem
|
public class GradesSummarySubItem
|
||||||
extends AbstractSectionableItem<GradesSummarySubItem.SubItemViewHolder, GradesSummaryHeader> {
|
extends AbstractSectionableItem<GradesSummarySubItem.SubItemViewHolder, GradesSummaryHeader> {
|
||||||
@ -76,8 +77,8 @@ public class GradesSummarySubItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onBind(Subject item) {
|
void onBind(Subject item) {
|
||||||
predictedGrade.setText(item.getPredictedRating());
|
predictedGrade.setText(GradeUtils.getShortGradeValue(item.getPredictedRating()));
|
||||||
finalGrade.setText(item.getFinalRating());
|
finalGrade.setText(GradeUtils.getShortGradeValue(item.getFinalRating()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ public final class GradeUtils {
|
|||||||
return counter / denominator;
|
return counter / denominator;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float getGradeValue(String grade) {
|
public static float getGradeValue(String grade) {
|
||||||
if (validGradePattern.matcher(grade).matches()) {
|
if (validGradePattern.matcher(grade).matches()) {
|
||||||
return getWeightedGradeValue(grade);
|
return getWeightedGradeValue(grade);
|
||||||
}
|
}
|
||||||
@ -128,6 +128,25 @@ public final class GradeUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getShortGradeValue(String grade) {
|
||||||
|
switch (grade) {
|
||||||
|
case "celujący":
|
||||||
|
return "6";
|
||||||
|
case "bardzo dobry":
|
||||||
|
return "5";
|
||||||
|
case "dobry":
|
||||||
|
return "4";
|
||||||
|
case "dostateczny":
|
||||||
|
return "3";
|
||||||
|
case "dopuszczający":
|
||||||
|
return "2";
|
||||||
|
case "niedostateczny":
|
||||||
|
return "1";
|
||||||
|
default:
|
||||||
|
return grade;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static float getWeightedGradeValue(String value) {
|
private static float getWeightedGradeValue(String value) {
|
||||||
if (validGradePattern.matcher(value).matches()) {
|
if (validGradePattern.matcher(value).matches()) {
|
||||||
if (value.matches("[-][0-6]") || value.matches("[0-6][-]")) {
|
if (value.matches("[-][0-6]") || value.matches("[0-6][-]")) {
|
||||||
|
@ -75,4 +75,11 @@ public class GradeUtilsTest {
|
|||||||
assertEquals(R.color.default_grade, GradeUtils.getValueColor("7"));
|
assertEquals(R.color.default_grade, GradeUtils.getValueColor("7"));
|
||||||
assertEquals(R.color.default_grade, GradeUtils.getValueColor(""));
|
assertEquals(R.color.default_grade, GradeUtils.getValueColor(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getShortGradeValueTest() {
|
||||||
|
assertEquals("6", GradeUtils.getShortGradeValue("celujący"));
|
||||||
|
assertEquals("1", GradeUtils.getShortGradeValue("niedostateczny"));
|
||||||
|
assertEquals("wzorowe", GradeUtils.getShortGradeValue("wzorowe"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user