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());
|
||||
|
||||
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,
|
||||
item.getFinalRating()));
|
||||
GradeUtils.getShortGradeValue(item.getFinalRating())));
|
||||
|
||||
resetViews();
|
||||
toggleSubjectText();
|
||||
|
@ -16,6 +16,7 @@ import eu.davidea.flexibleadapter.items.IFlexible;
|
||||
import eu.davidea.viewholders.FlexibleViewHolder;
|
||||
import io.github.wulkanowy.R;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Subject;
|
||||
import io.github.wulkanowy.utils.GradeUtils;
|
||||
|
||||
public class GradesSummarySubItem
|
||||
extends AbstractSectionableItem<GradesSummarySubItem.SubItemViewHolder, GradesSummaryHeader> {
|
||||
@ -76,8 +77,8 @@ public class GradesSummarySubItem
|
||||
}
|
||||
|
||||
void onBind(Subject item) {
|
||||
predictedGrade.setText(item.getPredictedRating());
|
||||
finalGrade.setText(item.getFinalRating());
|
||||
predictedGrade.setText(GradeUtils.getShortGradeValue(item.getPredictedRating()));
|
||||
finalGrade.setText(GradeUtils.getShortGradeValue(item.getFinalRating()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public final class GradeUtils {
|
||||
return counter / denominator;
|
||||
}
|
||||
|
||||
private static float getGradeValue(String grade) {
|
||||
public static float getGradeValue(String grade) {
|
||||
if (validGradePattern.matcher(grade).matches()) {
|
||||
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) {
|
||||
if (validGradePattern.matcher(value).matches()) {
|
||||
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(""));
|
||||
}
|
||||
|
||||
@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