forked from github/szkolny
[Agenda] Add showing teachers absence time hours
This commit is contained in:
parent
fea51fc493
commit
fd034128e8
@ -3189,6 +3189,14 @@ public class Librus implements EdziennikInterface {
|
||||
Date dateFrom = Date.fromY_m_d(freeDay.get("DateFrom").getAsString());
|
||||
Date dateTo = Date.fromY_m_d(freeDay.get("DateTo").getAsString());
|
||||
|
||||
Time timeFrom = null;
|
||||
Time timeTo = null;
|
||||
|
||||
if (freeDay.get("TimeFrom") != null && freeDay.get("TimeTo") != null) {
|
||||
timeFrom = Time.fromH_m_s(freeDay.get("TimeFrom").getAsString());
|
||||
timeTo = Time.fromH_m_s(freeDay.get("TimeTo").getAsString());
|
||||
}
|
||||
|
||||
long type = freeDay.getAsJsonObject("Type").get("Id").getAsLong();
|
||||
|
||||
//String topic = teacherFreeDaysTypes.get(type)+"\n"+(dateFrom.getValue() != dateTo.getValue() ? dateFrom.getFormattedString()+" - "+dateTo.getFormattedString() : "");
|
||||
@ -3199,7 +3207,9 @@ public class Librus implements EdziennikInterface {
|
||||
teacherId,
|
||||
type,
|
||||
dateFrom,
|
||||
dateTo
|
||||
dateTo,
|
||||
timeFrom,
|
||||
timeTo
|
||||
);
|
||||
|
||||
teacherAbsenceList.add(teacherAbsence);
|
||||
|
@ -81,7 +81,7 @@ import android.content.Context;
|
||||
Message.class,
|
||||
MessageRecipient.class,
|
||||
DebugLog.class,
|
||||
Metadata.class}, version = 53)
|
||||
Metadata.class}, version = 54)
|
||||
@TypeConverters({
|
||||
ConverterTime.class,
|
||||
ConverterDate.class,
|
||||
@ -551,6 +551,13 @@ public abstract class AppDb extends RoomDatabase {
|
||||
")");
|
||||
}
|
||||
};
|
||||
private static final Migration MIGRATION_53_54 = new Migration(53, 54) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
database.execSQL("ALTER TABLE teacherAbsence ADD teacherAbsenceTimeFrom TEXT DEFAULT NULL");
|
||||
database.execSQL("ALTER TABLE teacherAbsence ADD teacherAbsenceTimeTo TEXT DEFAULT NULL");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public static AppDb getDatabase(final Context context) {
|
||||
@ -601,7 +608,9 @@ public abstract class AppDb extends RoomDatabase {
|
||||
MIGRATION_49_50,
|
||||
MIGRATION_50_51,
|
||||
MIGRATION_51_52,
|
||||
MIGRATION_52_53)
|
||||
MIGRATION_52_53,
|
||||
MIGRATION_53_54
|
||||
)
|
||||
.allowMainThreadQueries()
|
||||
//.fallbackToDestructiveMigration()
|
||||
.build();
|
||||
|
@ -3,6 +3,7 @@ package pl.szczodrzynski.edziennik.data.db.modules.teachers
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
|
||||
@Entity(tableName = "teacherAbsence",
|
||||
primaryKeys = ["profileId", "teacherAbsenceId"])
|
||||
@ -22,6 +23,12 @@ open class TeacherAbsence (
|
||||
val dateFrom: Date,
|
||||
|
||||
@ColumnInfo(name = "teacherAbsenceDateTo")
|
||||
val dateTo: Date
|
||||
val dateTo: Date,
|
||||
|
||||
@ColumnInfo(name = "teacherAbsenceTimeFrom")
|
||||
val timeFrom: Time?,
|
||||
|
||||
@ColumnInfo(name = "teacherAbsenceTimeTo")
|
||||
val timeTo: Time?
|
||||
|
||||
)
|
||||
|
@ -1,9 +1,11 @@
|
||||
package pl.szczodrzynski.edziennik.data.db.modules.teachers
|
||||
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
|
||||
class TeacherAbsenceFull(profileId: Int, id: Long, teacherId: Long, type: Long, dateFrom: Date, dateTo: Date)
|
||||
: TeacherAbsence(profileId, id, teacherId, type, dateFrom, dateTo) {
|
||||
class TeacherAbsenceFull(profileId: Int, id: Long, teacherId: Long, type: Long,
|
||||
dateFrom: Date, dateTo: Date, timeFrom: Time?, timeTo: Time?)
|
||||
: TeacherAbsence(profileId, id, teacherId, type, dateFrom, dateTo, timeFrom, timeTo) {
|
||||
|
||||
var teacherFullName = ""
|
||||
|
||||
|
@ -31,9 +31,19 @@ class TeacherAbsenceAdapter(
|
||||
|
||||
holder.teacherAbsenceTeacher.text = teacherAbsence.teacherFullName
|
||||
|
||||
val time = when(teacherAbsence.dateFrom.compareTo(teacherAbsence.dateTo)) {
|
||||
0 -> teacherAbsence.dateFrom.formattedStringShort
|
||||
else -> teacherAbsence.dateFrom.formattedStringShort + " - " + teacherAbsence.dateTo.formattedStringShort
|
||||
val time = when (teacherAbsence.timeFrom != null && teacherAbsence.timeTo != null) {
|
||||
true -> when (teacherAbsence.dateFrom.compareTo(teacherAbsence.dateTo)) {
|
||||
0 -> teacherAbsence.dateFrom.formattedStringShort + " " +
|
||||
teacherAbsence.timeFrom.stringHM + " - " + teacherAbsence.timeTo.stringHM
|
||||
|
||||
else -> teacherAbsence.dateFrom.formattedStringShort + " " + teacherAbsence.timeTo.stringHM +
|
||||
" - " + teacherAbsence.dateTo.formattedStringShort + " " + teacherAbsence.timeTo.stringHM
|
||||
}
|
||||
|
||||
false -> when (teacherAbsence.dateFrom.compareTo(teacherAbsence.dateTo)) {
|
||||
0 -> teacherAbsence.dateFrom.formattedStringShort
|
||||
else -> teacherAbsence.dateFrom.formattedStringShort + " - " + teacherAbsence.dateTo.formattedStringShort
|
||||
}
|
||||
}
|
||||
|
||||
holder.teacherAbsenceTime.text = time
|
||||
|
@ -56,6 +56,9 @@ public class Time {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* HHMMSS
|
||||
*/
|
||||
public static Time fromHms(String time)
|
||||
{
|
||||
try {
|
||||
@ -67,6 +70,9 @@ public class Time {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HH:MM
|
||||
*/
|
||||
public static Time fromH_m(String time)
|
||||
{
|
||||
try {
|
||||
@ -78,6 +84,9 @@ public class Time {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HH:MM:SS
|
||||
*/
|
||||
public static Time fromH_m_s(String time)
|
||||
{
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user