1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-09-20 02:09:09 -05:00

Hide empty fields in summary (#128)

This commit is contained in:
Mikołaj Pich 2018-05-31 23:01:52 +02:00 committed by Rafał Borcz
parent 306092ce45
commit 228f680e5d

View File

@ -118,57 +118,13 @@ public class GradeHeaderItem
item.getFinalRating()));
resetViews();
toggleSummaryText();
toggleSubjectText();
toggleSummary();
alertImage.setVisibility(isSubItemsReadAndSaveAlertView(subItems)
? View.INVISIBLE : View.VISIBLE);
}
@Override
public void onClick(View view) {
super.onClick(view);
toggleSubjectText();
toggleSummaryText();
}
private void toggleSummaryText() {
if (isSummaryToggleable()) {
if (isExpand()) {
AnimationUtils.slideDown(predictedText);
AnimationUtils.slideDown(finalText);
} else {
AnimationUtils.slideUp(predictedText);
AnimationUtils.slideUp(finalText);
}
}
}
private void toggleSubjectText() {
if (isExpand()) {
subjectName.setMaxLines(3);
} else {
subjectName.setMaxLines(1);
}
}
private void resetViews() {
subjectName.setMaxLines(1);
predictedText.setVisibility(View.GONE);
finalText.setVisibility(View.GONE);
}
private boolean isSubItemsReadAndSaveAlertView(List<GradesSubItem> subItems) {
boolean isRead = true;
for (GradesSubItem gradesSubItem : subItems) {
isRead = gradesSubItem.getGrade().getRead();
gradesSubItem.setSubjectAlertImage(alertImage);
}
return isRead;
}
private String getGradesAverageString() {
float average = GradeUtils.calculate(item.getGradeList());
@ -179,26 +135,65 @@ public class GradeHeaderItem
return resources.getString(R.string.info_average_grades, average);
}
@Override
public void onClick(View view) {
super.onClick(view);
toggleSubjectText();
toggleSummary();
}
private void resetViews() {
subjectName.setMaxLines(1);
setDefaultSummaryVisibility(predictedText, item.getPredictedRating());
setDefaultSummaryVisibility(finalText, item.getFinalRating());
}
private void setDefaultSummaryVisibility(View view, String value) {
if (!"-".equals(value) && isShowSummary) {
view.setVisibility(View.VISIBLE);
} else {
view.setVisibility(View.GONE);
}
}
private void toggleSubjectText() {
if (isExpand()) {
subjectName.setMaxLines(3);
} else {
subjectName.setMaxLines(1);
}
}
private void toggleSummary() {
toggleSummaryView(predictedText, item.getPredictedRating(), isExpand());
toggleSummaryView(finalText, item.getFinalRating(), isExpand());
}
private boolean isExpand() {
return adapter.isExpanded(getFlexibleAdapterPosition());
}
private boolean isSummaryToggleable() {
boolean isSummaryEmpty = true;
if (!"-".equals(item.getPredictedRating()) || !"-".equals(item.getFinalRating())) {
isSummaryEmpty = false;
private void toggleSummaryView(View view, String value, boolean expand) {
if ("-".equals(value) || isShowSummary) {
return;
}
if (isSummaryEmpty) {
return false;
} else if (isShowSummary) {
predictedText.setVisibility(View.VISIBLE);
finalText.setVisibility(View.VISIBLE);
if (expand) {
AnimationUtils.slideDown(view);
} else {
AnimationUtils.slideUp(view);
}
}
return false;
private boolean isSubItemsReadAndSaveAlertView(List<GradesSubItem> subItems) {
boolean isRead = true;
for (GradesSubItem gradesSubItem : subItems) {
isRead = gradesSubItem.getGrade().getRead();
gradesSubItem.setSubjectAlertImage(alertImage);
}
return true;
return isRead;
}
}
}