mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 12:56:45 -06:00
[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) {
|
if (model is GradesSubject) {
|
||||||
|
// hide the preview, show summary
|
||||||
val preview = view?.findViewById<View>(R.id.previewContainer)
|
val preview = view?.findViewById<View>(R.id.previewContainer)
|
||||||
val summary = view?.findViewById<View>(R.id.yearSummary)
|
val summary = view?.findViewById<View>(R.id.yearSummary)
|
||||||
preview?.visibility = if (model.state == STATE_CLOSED) View.INVISIBLE else View.VISIBLE
|
preview?.visibility = if (model.state == STATE_CLOSED) View.INVISIBLE else View.VISIBLE
|
||||||
summary?.visibility = if (model.state == STATE_CLOSED) View.VISIBLE else View.INVISIBLE
|
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) {
|
if (model.state == STATE_CLOSED) {
|
||||||
|
@ -204,7 +204,10 @@ class GradesListFragment : Fragment(), CoroutineScope {
|
|||||||
|
|
||||||
grade.showAsUnseen = !grade.seen
|
grade.showAsUnseen = !grade.seen
|
||||||
if (!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) {
|
when (grade.type) {
|
||||||
|
@ -16,8 +16,8 @@ data class GradesSubject(
|
|||||||
var lastAddedDate = 0L
|
var lastAddedDate = 0L
|
||||||
var semester: Int = 1
|
var semester: Int = 1
|
||||||
|
|
||||||
val hasUnseen
|
var hasUnseen: Boolean = false
|
||||||
get() = semesters.any { it.hasUnseen }
|
get() = field || semesters.any { it.hasUnseen }
|
||||||
|
|
||||||
val averages = GradesAverages()
|
val averages = GradesAverages()
|
||||||
var proposedGrade: GradeFull? = null
|
var proposedGrade: GradeFull? = null
|
||||||
|
@ -96,6 +96,7 @@ class SubjectViewHolder(
|
|||||||
ellipsize = TextUtils.TruncateAt.END
|
ellipsize = TextUtils.TruncateAt.END
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// add the topmost semester's grades to preview container (collapsed)
|
||||||
firstSemester.proposedGrade?.let {
|
firstSemester.proposedGrade?.let {
|
||||||
b.previewContainer.addView(GradeView(
|
b.previewContainer.addView(GradeView(
|
||||||
contextWrapper,
|
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) {
|
if (firstSemester.number == item.semester) {
|
||||||
b.previewContainer.addView(TextView(contextWrapper).apply {
|
b.previewContainer.addView(TextView(contextWrapper).apply {
|
||||||
text = manager.getAverageString(app, item.averages, nameSemester = true)
|
text = manager.getAverageString(app, item.averages, nameSemester = true)
|
||||||
|
@ -65,39 +65,52 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_marginLeft="8dp">
|
android:layout_marginBottom="8dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/previewContainer"
|
android:id="@+id/previewContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:baselineAligned="false"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
tools:visibility="visible"
|
tools:visibility="visible">
|
||||||
android:baselineAligned="false">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/gradesContainer"
|
android:id="@+id/gradesContainer"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginRight="8dp"
|
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:layout_weight="1"
|
||||||
android:orientation="horizontal" />
|
android:orientation="horizontal" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/yearSummary"
|
android:id="@+id/yearContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:baselineAligned="false"
|
||||||
android:textSize="14sp"
|
android:orientation="horizontal"
|
||||||
android:visibility="gone"
|
tools:visibility="visible">
|
||||||
tools:text1="Cały rok: 3 oceny • suma: 320 pkt"
|
|
||||||
tools:text2="Cały rok: 15 ocen • średnia: 2,62"
|
<TextView
|
||||||
tools:text="Cały rok: 6 ocen • punkty: 34.20/40 (87.5%)"
|
android:id="@+id/yearSummary"
|
||||||
tools:visibility="visible"/>
|
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>
|
</FrameLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user