[Agenda] Add teacher absence in event list dialog

This commit is contained in:
Kacper Ziubryniewicz 2019-09-29 17:40:54 +02:00
parent b17675ec0c
commit 2c4e0e3121
7 changed files with 47 additions and 11 deletions

View File

@ -20,7 +20,9 @@ import pl.szczodrzynski.edziennik.App;
import pl.szczodrzynski.edziennik.R;
import pl.szczodrzynski.edziennik.data.db.modules.lessons.LessonChange;
import pl.szczodrzynski.edziennik.data.db.modules.lessons.LessonFull;
import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsenceFull;
import pl.szczodrzynski.edziennik.ui.dialogs.lessonchange.LessonChangeDialog;
import pl.szczodrzynski.edziennik.ui.dialogs.teacherabsence.TeacherAbsenceDialog;
import pl.szczodrzynski.edziennik.utils.models.Date;
import pl.szczodrzynski.edziennik.utils.models.Time;
@ -171,7 +173,8 @@ public class EventListDialog {
examsView.setNestedScrollingEnabled(false);
examsView.setLayoutManager(new LinearLayoutManager(context));
CardView lessonChangeContainer = dialogView.findViewById(R.id.lesson_change_container);
CardView lessonChangeContainer = dialogView.findViewById(R.id.lessonChangeContainer);
CardView teacherAbsenceContainer = dialogView.findViewById(R.id.teacherAbsenceContainer);
//lessonChangeContainer.setVisibility(View.GONE);
if (time == null) {
app.db.lessonChangeDao().getLessonChangeCounterByDate(App.profileId, date).observe((LifecycleOwner) context, counter -> {
@ -179,14 +182,38 @@ public class EventListDialog {
return;
if (counter.lessonChangeCount > 0) {
lessonChangeContainer.setVisibility(View.VISIBLE);
TextView lessonChangeCount = dialogView.findViewById(R.id.lesson_change_count);
lessonChangeCount.setText(Integer.toString(counter.lessonChangeCount));
TextView lessonChangeCount = dialogView.findViewById(R.id.lessonChangeCount);
lessonChangeCount.setText(String.valueOf(counter.lessonChangeCount));
lessonChangeContainer.setCardBackgroundColor(0xff78909c);
lessonChangeContainer.setOnClickListener((v -> {
new LessonChangeDialog(context).show(app, date);
}));
}
});
app.db.teacherAbsenceDao().getAllByDateFull(App.profileId, date).observe((LifecycleOwner) context, teacherAbsenceList -> {
if (teacherAbsenceList == null)
return;
if (teacherAbsenceList.size() > 0) {
int count = 0;
for (TeacherAbsenceFull teacherAbsence : teacherAbsenceList) {
Date dateFrom = teacherAbsence.getDateFrom();
Date dateTo = teacherAbsence.getDateTo();
if (date.compareTo(dateFrom) >= 0 && date.compareTo(dateTo) <= 0) {
count++;
}
}
teacherAbsenceContainer.setVisibility(View.VISIBLE);
TextView teacherAbsenceCount = dialogView.findViewById(R.id.teacherAbsenceCount);
teacherAbsenceCount.setText(String.valueOf(count));
teacherAbsenceContainer.setCardBackgroundColor(0xffff1744);
teacherAbsenceContainer.setOnClickListener(( v -> {
new TeacherAbsenceDialog(context).show(app, date);
}));
}
});
}
app.db.eventDao().getAllByDateTime(profileId, date, time).observe((LifecycleOwner) context, events -> {

View File

@ -210,8 +210,8 @@ public class AgendaFragment extends Fragment {
endTime.setTimeInMillis(startTime.getTimeInMillis() + (1000 * 60 * 45));
eventList.add(new TeacherAbsenceEvent(
date.getInMillis(),
0xff8f0119,
Colors.legibleTextColor(0xff8f0119),
0xffff1744,
Colors.legibleTextColor(0xffff1744),
startTime,
endTime,
App.profileId,

View File

@ -14,7 +14,7 @@ public class LessonChangeEventRenderer extends EventRenderer<LessonChangeEvent>
public void render(View view, LessonChangeEvent event) {
CardView card = view.findViewById(R.id.lesson_change_card);
TextView changeText = view.findViewById(R.id.lesson_change_text);
TextView changeCount = view.findViewById(R.id.lesson_change_count);
TextView changeCount = view.findViewById(R.id.lessonChangeCount);
card.setCardBackgroundColor(event.getColor());
changeText.setTextColor(event.getTextColor());
changeCount.setTextColor(event.getTextColor());

View File

@ -15,7 +15,7 @@
app:layout_constraintTop_toTopOf="parent">
<include
android:id="@+id/lesson_change_container"
android:id="@+id/lessonChangeContainer"
layout="@layout/row_lesson_change_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -23,6 +23,15 @@
android:visibility="gone"
tools:visibility="visible" />
<include
android:id="@+id/teacherAbsenceContainer"
layout="@layout/row_teacher_absence_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:visibility="gone"
tools:visibility="visible" />
<LinearLayout
android:id="@+id/eventListLessonDetails"
android:layout_width="match_parent"

View File

@ -23,7 +23,7 @@
android:text="@string/agenda_lesson_changes" />
<TextView
android:id="@+id/lesson_change_count"
android:id="@+id/lessonChangeCount"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
@ -32,4 +32,4 @@
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView>

View File

@ -851,7 +851,7 @@
<string name="messages_compose_menu_discard">Abort message</string>
<string name="messages_compose_menu_save_draft">Save draft</string>
<string name="messages_compose_menu_send">Send</string>
<string name="agenda_teacher_absence">Teachers absence</string>
<string name="agenda_teacher_absence">Absent teachers</string>
<string name="sync_action_syncing_grade_comments">Getting grade comments</string>
<string name="sync_action_syncing_school_free_days">Getting school free days</string>
</resources>

View File

@ -908,6 +908,6 @@
<string name="homework_tab_current">Aktualne</string>
<string name="homework_tab_past">Minione</string>
<string name="homework_no_data">Brak zadań domowych.</string>
<string name="agenda_teacher_absence">Nieobecność nauczycieli</string>
<string name="agenda_teacher_absence">Nieobecni nauczyciele</string>
<string name="sync_action_syncing_grade_comments">Pobieranie komentarzy ocen</string>
</resources>