forked from github/szkolny
[Grades] Fix marking yearly grades as seen.
This commit is contained in:
parent
0413dbffa2
commit
f07b12bd87
@ -99,10 +99,31 @@ class GradesAdapter(
|
||||
}
|
||||
}
|
||||
if (model is GradesSubject) {
|
||||
// hide the preview, show summary
|
||||
val preview = view?.findViewById<View>(R.id.previewContainer)
|
||||
val summary = view?.findViewById<View>(R.id.yearSummary)
|
||||
preview?.visibility = if (model.state == STATE_CLOSED) View.INVISIBLE else View.VISIBLE
|
||||
summary?.visibility = if (model.state == STATE_CLOSED) View.VISIBLE else View.INVISIBLE
|
||||
|
||||
// expanding a subject - mark proposed & final grade as seen
|
||||
var unseenChanged = false
|
||||
if (model.proposedGrade?.seen == false) {
|
||||
manager.markAsSeen(model.proposedGrade!!)
|
||||
unseenChanged = true
|
||||
}
|
||||
if (model.finalGrade?.seen == false) {
|
||||
manager.markAsSeen(model.finalGrade!!)
|
||||
unseenChanged = true
|
||||
}
|
||||
// remove the override flag
|
||||
model.hasUnseen = false
|
||||
|
||||
if (unseenChanged) {
|
||||
// check if the unseen status has changed
|
||||
if (!model.hasUnseen) {
|
||||
notifyItemChanged(model)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (model.state == STATE_CLOSED) {
|
||||
|
@ -204,7 +204,10 @@ class GradesListFragment : Fragment(), CoroutineScope {
|
||||
|
||||
grade.showAsUnseen = !grade.seen
|
||||
if (!grade.seen) {
|
||||
semester.hasUnseen = true
|
||||
if (grade.type == Grade.TYPE_YEAR_PROPOSED || grade.type == Grade.TYPE_YEAR_FINAL)
|
||||
subject.hasUnseen = true // set an override flag
|
||||
else
|
||||
semester.hasUnseen = true
|
||||
}
|
||||
|
||||
when (grade.type) {
|
||||
|
@ -16,8 +16,8 @@ data class GradesSubject(
|
||||
var lastAddedDate = 0L
|
||||
var semester: Int = 1
|
||||
|
||||
val hasUnseen
|
||||
get() = semesters.any { it.hasUnseen }
|
||||
var hasUnseen: Boolean = false
|
||||
get() = field || semesters.any { it.hasUnseen }
|
||||
|
||||
val averages = GradesAverages()
|
||||
var proposedGrade: GradeFull? = null
|
||||
|
@ -96,6 +96,7 @@ class SubjectViewHolder(
|
||||
ellipsize = TextUtils.TruncateAt.END
|
||||
})
|
||||
|
||||
// add the topmost semester's grades to preview container (collapsed)
|
||||
firstSemester.proposedGrade?.let {
|
||||
b.previewContainer.addView(GradeView(
|
||||
contextWrapper,
|
||||
@ -111,6 +112,23 @@ class SubjectViewHolder(
|
||||
))
|
||||
}
|
||||
|
||||
// add the yearly grades to summary container (expanded)
|
||||
item.proposedGrade?.let {
|
||||
b.yearContainer.addView(GradeView(
|
||||
contextWrapper,
|
||||
it,
|
||||
manager
|
||||
))
|
||||
}
|
||||
item.finalGrade?.let {
|
||||
b.yearContainer.addView(GradeView(
|
||||
contextWrapper,
|
||||
it,
|
||||
manager
|
||||
))
|
||||
}
|
||||
|
||||
// if showing semester 2, add yearly grades to preview container (collapsed)
|
||||
if (firstSemester.number == item.semester) {
|
||||
b.previewContainer.addView(TextView(contextWrapper).apply {
|
||||
text = manager.getAverageString(app, item.averages, nameSemester = true)
|
||||
|
@ -65,39 +65,52 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="8dp">
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginBottom="8dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/previewContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal"
|
||||
tools:visibility="visible"
|
||||
android:baselineAligned="false">
|
||||
tools:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/gradesContainer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/yearSummary"
|
||||
<LinearLayout
|
||||
android:id="@+id/yearContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textSize="14sp"
|
||||
android:visibility="gone"
|
||||
tools:text1="Cały rok: 3 oceny • suma: 320 pkt"
|
||||
tools:text2="Cały rok: 15 ocen • średnia: 2,62"
|
||||
tools:text="Cały rok: 6 ocen • punkty: 34.20/40 (87.5%)"
|
||||
tools:visibility="visible"/>
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/yearSummary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_weight="1"
|
||||
android:textSize="14sp"
|
||||
android:visibility="gone"
|
||||
tools:text="Cały rok: 6 ocen • punkty: 34.20/40 (87.5%)"
|
||||
tools:text1="Cały rok: 3 oceny • suma: 320 pkt"
|
||||
tools:text2="Cały rok: 15 ocen • średnia: 2,62"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user