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 dateFrom = Date.fromY_m_d(freeDay.get("DateFrom").getAsString());
|
||||||
Date dateTo = Date.fromY_m_d(freeDay.get("DateTo").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();
|
long type = freeDay.getAsJsonObject("Type").get("Id").getAsLong();
|
||||||
|
|
||||||
//String topic = teacherFreeDaysTypes.get(type)+"\n"+(dateFrom.getValue() != dateTo.getValue() ? dateFrom.getFormattedString()+" - "+dateTo.getFormattedString() : "");
|
//String topic = teacherFreeDaysTypes.get(type)+"\n"+(dateFrom.getValue() != dateTo.getValue() ? dateFrom.getFormattedString()+" - "+dateTo.getFormattedString() : "");
|
||||||
@ -3199,7 +3207,9 @@ public class Librus implements EdziennikInterface {
|
|||||||
teacherId,
|
teacherId,
|
||||||
type,
|
type,
|
||||||
dateFrom,
|
dateFrom,
|
||||||
dateTo
|
dateTo,
|
||||||
|
timeFrom,
|
||||||
|
timeTo
|
||||||
);
|
);
|
||||||
|
|
||||||
teacherAbsenceList.add(teacherAbsence);
|
teacherAbsenceList.add(teacherAbsence);
|
||||||
|
@ -81,7 +81,7 @@ import android.content.Context;
|
|||||||
Message.class,
|
Message.class,
|
||||||
MessageRecipient.class,
|
MessageRecipient.class,
|
||||||
DebugLog.class,
|
DebugLog.class,
|
||||||
Metadata.class}, version = 53)
|
Metadata.class}, version = 54)
|
||||||
@TypeConverters({
|
@TypeConverters({
|
||||||
ConverterTime.class,
|
ConverterTime.class,
|
||||||
ConverterDate.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) {
|
public static AppDb getDatabase(final Context context) {
|
||||||
@ -601,7 +608,9 @@ public abstract class AppDb extends RoomDatabase {
|
|||||||
MIGRATION_49_50,
|
MIGRATION_49_50,
|
||||||
MIGRATION_50_51,
|
MIGRATION_50_51,
|
||||||
MIGRATION_51_52,
|
MIGRATION_51_52,
|
||||||
MIGRATION_52_53)
|
MIGRATION_52_53,
|
||||||
|
MIGRATION_53_54
|
||||||
|
)
|
||||||
.allowMainThreadQueries()
|
.allowMainThreadQueries()
|
||||||
//.fallbackToDestructiveMigration()
|
//.fallbackToDestructiveMigration()
|
||||||
.build();
|
.build();
|
||||||
|
@ -3,6 +3,7 @@ package pl.szczodrzynski.edziennik.data.db.modules.teachers
|
|||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
|
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||||
|
|
||||||
@Entity(tableName = "teacherAbsence",
|
@Entity(tableName = "teacherAbsence",
|
||||||
primaryKeys = ["profileId", "teacherAbsenceId"])
|
primaryKeys = ["profileId", "teacherAbsenceId"])
|
||||||
@ -22,6 +23,12 @@ open class TeacherAbsence (
|
|||||||
val dateFrom: Date,
|
val dateFrom: Date,
|
||||||
|
|
||||||
@ColumnInfo(name = "teacherAbsenceDateTo")
|
@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
|
package pl.szczodrzynski.edziennik.data.db.modules.teachers
|
||||||
|
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
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)
|
class TeacherAbsenceFull(profileId: Int, id: Long, teacherId: Long, type: Long,
|
||||||
: TeacherAbsence(profileId, id, teacherId, type, dateFrom, dateTo) {
|
dateFrom: Date, dateTo: Date, timeFrom: Time?, timeTo: Time?)
|
||||||
|
: TeacherAbsence(profileId, id, teacherId, type, dateFrom, dateTo, timeFrom, timeTo) {
|
||||||
|
|
||||||
var teacherFullName = ""
|
var teacherFullName = ""
|
||||||
|
|
||||||
|
@ -31,9 +31,19 @@ class TeacherAbsenceAdapter(
|
|||||||
|
|
||||||
holder.teacherAbsenceTeacher.text = teacherAbsence.teacherFullName
|
holder.teacherAbsenceTeacher.text = teacherAbsence.teacherFullName
|
||||||
|
|
||||||
val time = when(teacherAbsence.dateFrom.compareTo(teacherAbsence.dateTo)) {
|
val time = when (teacherAbsence.timeFrom != null && teacherAbsence.timeTo != null) {
|
||||||
0 -> teacherAbsence.dateFrom.formattedStringShort
|
true -> when (teacherAbsence.dateFrom.compareTo(teacherAbsence.dateTo)) {
|
||||||
else -> teacherAbsence.dateFrom.formattedStringShort + " - " + teacherAbsence.dateTo.formattedStringShort
|
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
|
holder.teacherAbsenceTime.text = time
|
||||||
|
@ -56,6 +56,9 @@ public class Time {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HHMMSS
|
||||||
|
*/
|
||||||
public static Time fromHms(String time)
|
public static Time fromHms(String time)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -67,6 +70,9 @@ public class Time {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HH:MM
|
||||||
|
*/
|
||||||
public static Time fromH_m(String time)
|
public static Time fromH_m(String time)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -78,6 +84,9 @@ public class Time {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HH:MM:SS
|
||||||
|
*/
|
||||||
public static Time fromH_m_s(String time)
|
public static Time fromH_m_s(String time)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user