mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 12:56:45 -06:00
[APIv2/Librus] Add getting and showing teacher absence reason
This commit is contained in:
parent
cf8afc03bc
commit
e138ca6eab
@ -40,6 +40,7 @@ const val ENDPOINT_LIBRUS_API_ATTENDANCE_TYPES = 1080
|
|||||||
const val ENDPOINT_LIBRUS_API_ATTENDANCES = 1081
|
const val ENDPOINT_LIBRUS_API_ATTENDANCES = 1081
|
||||||
const val ENDPOINT_LIBRUS_API_ANNOUNCEMENTS = 1090
|
const val ENDPOINT_LIBRUS_API_ANNOUNCEMENTS = 1090
|
||||||
const val ENDPOINT_LIBRUS_API_PT_MEETINGS = 1100
|
const val ENDPOINT_LIBRUS_API_PT_MEETINGS = 1100
|
||||||
|
const val ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES = 1109
|
||||||
const val ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS = 1110
|
const val ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS = 1110
|
||||||
const val ENDPOINT_LIBRUS_API_SCHOOL_FREE_DAYS = 1120
|
const val ENDPOINT_LIBRUS_API_SCHOOL_FREE_DAYS = 1120
|
||||||
const val ENDPOINT_LIBRUS_API_CLASS_FREE_DAYS = 1130
|
const val ENDPOINT_LIBRUS_API_CLASS_FREE_DAYS = 1130
|
||||||
@ -79,6 +80,7 @@ val LibrusFeatures = listOf(
|
|||||||
ENDPOINT_LIBRUS_API_EVENTS to LOGIN_METHOD_LIBRUS_API,
|
ENDPOINT_LIBRUS_API_EVENTS to LOGIN_METHOD_LIBRUS_API,
|
||||||
ENDPOINT_LIBRUS_API_EVENT_TYPES to LOGIN_METHOD_LIBRUS_API,
|
ENDPOINT_LIBRUS_API_EVENT_TYPES to LOGIN_METHOD_LIBRUS_API,
|
||||||
ENDPOINT_LIBRUS_API_PT_MEETINGS to LOGIN_METHOD_LIBRUS_API,
|
ENDPOINT_LIBRUS_API_PT_MEETINGS to LOGIN_METHOD_LIBRUS_API,
|
||||||
|
ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES to LOGIN_METHOD_LIBRUS_API,
|
||||||
ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS to LOGIN_METHOD_LIBRUS_API,
|
ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS to LOGIN_METHOD_LIBRUS_API,
|
||||||
ENDPOINT_LIBRUS_API_SCHOOL_FREE_DAYS to LOGIN_METHOD_LIBRUS_API,
|
ENDPOINT_LIBRUS_API_SCHOOL_FREE_DAYS to LOGIN_METHOD_LIBRUS_API,
|
||||||
ENDPOINT_LIBRUS_API_CLASS_FREE_DAYS to LOGIN_METHOD_LIBRUS_API
|
ENDPOINT_LIBRUS_API_CLASS_FREE_DAYS to LOGIN_METHOD_LIBRUS_API
|
||||||
|
@ -75,6 +75,10 @@ class LibrusData(val data: DataLibrus, val onSuccess: () -> Unit) {
|
|||||||
data.startProgress(R.string.edziennik_progress_endpoint_classes)
|
data.startProgress(R.string.edziennik_progress_endpoint_classes)
|
||||||
LibrusApiClasses(data) { onSuccess() }
|
LibrusApiClasses(data) { onSuccess() }
|
||||||
}
|
}
|
||||||
|
ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES -> {
|
||||||
|
data.startProgress(R.string.edziennik_progress_endpoint_teacher_free_day_types)
|
||||||
|
LibrusApiTeacherFreeDayTypes(data) { onSuccess() }
|
||||||
|
}
|
||||||
ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS -> {
|
ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS -> {
|
||||||
data.startProgress(R.string.edziennik_progress_endpoint_teacher_free_days)
|
data.startProgress(R.string.edziennik_progress_endpoint_teacher_free_days)
|
||||||
LibrusApiTeacherFreeDays(data) { onSuccess() }
|
LibrusApiTeacherFreeDays(data) { onSuccess() }
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2019-10-19
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.api.v2.librus.data.api
|
||||||
|
|
||||||
|
import pl.szczodrzynski.edziennik.DAY
|
||||||
|
import pl.szczodrzynski.edziennik.api.v2.librus.DataLibrus
|
||||||
|
import pl.szczodrzynski.edziennik.api.v2.librus.ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES
|
||||||
|
import pl.szczodrzynski.edziennik.api.v2.librus.data.LibrusApi
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsenceType
|
||||||
|
import pl.szczodrzynski.edziennik.getJsonArray
|
||||||
|
import pl.szczodrzynski.edziennik.getLong
|
||||||
|
import pl.szczodrzynski.edziennik.getString
|
||||||
|
|
||||||
|
class LibrusApiTeacherFreeDayTypes(override val data: DataLibrus,
|
||||||
|
val onSuccess: () -> Unit) : LibrusApi(data) {
|
||||||
|
companion object {
|
||||||
|
const val TAG = "LibrusApiTeacherFreeDayTypes"
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
apiGet(TAG, "TeacherFreeDays/Types") { json ->
|
||||||
|
val teacherAbsenceTypes = json.getJsonArray("Types")
|
||||||
|
|
||||||
|
teacherAbsenceTypes?.forEach { teacherAbsenceTypeEl ->
|
||||||
|
val teacherAbsenceType = teacherAbsenceTypeEl.asJsonObject
|
||||||
|
|
||||||
|
val id = teacherAbsenceType.getLong("Id") ?: return@forEach
|
||||||
|
val name = teacherAbsenceType.getString("Name") ?: return@forEach
|
||||||
|
|
||||||
|
val teacherAbsenceTypeObject = TeacherAbsenceType(
|
||||||
|
profileId,
|
||||||
|
id,
|
||||||
|
name
|
||||||
|
)
|
||||||
|
|
||||||
|
data.teacherAbsenceTypes.put(id, teacherAbsenceTypeObject)
|
||||||
|
}
|
||||||
|
|
||||||
|
data.setSyncNext(ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES, 4 * DAY)
|
||||||
|
onSuccess()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -30,6 +30,7 @@ class LibrusApiTeacherFreeDays(override val data: DataLibrus,
|
|||||||
val teacherId = teacherAbsence.getJsonObject("Teacher")?.getLong("Id")
|
val teacherId = teacherAbsence.getJsonObject("Teacher")?.getLong("Id")
|
||||||
?: return@forEach
|
?: return@forEach
|
||||||
val type = teacherAbsence.getJsonObject("Type").getLong("Id") ?: return@forEach
|
val type = teacherAbsence.getJsonObject("Type").getLong("Id") ?: return@forEach
|
||||||
|
val name = data.teacherAbsenceTypes.singleOrNull { it.id == type }?.name
|
||||||
val dateFrom = Date.fromY_m_d(teacherAbsence.getString("DateFrom"))
|
val dateFrom = Date.fromY_m_d(teacherAbsence.getString("DateFrom"))
|
||||||
val dateTo = Date.fromY_m_d(teacherAbsence.getString("DateTo"))
|
val dateTo = Date.fromY_m_d(teacherAbsence.getString("DateTo"))
|
||||||
val timeFrom = teacherAbsence.getString("TimeFrom")?.let { Time.fromH_m_s(it) }
|
val timeFrom = teacherAbsence.getString("TimeFrom")?.let { Time.fromH_m_s(it) }
|
||||||
@ -40,6 +41,7 @@ class LibrusApiTeacherFreeDays(override val data: DataLibrus,
|
|||||||
id,
|
id,
|
||||||
teacherId,
|
teacherId,
|
||||||
type,
|
type,
|
||||||
|
name,
|
||||||
dateFrom,
|
dateFrom,
|
||||||
dateTo,
|
dateTo,
|
||||||
timeFrom,
|
timeFrom,
|
||||||
|
@ -32,6 +32,7 @@ import pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile
|
|||||||
import pl.szczodrzynski.edziennik.data.db.modules.subjects.Subject
|
import pl.szczodrzynski.edziennik.data.db.modules.subjects.Subject
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.teachers.Teacher
|
import pl.szczodrzynski.edziennik.data.db.modules.teachers.Teacher
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsence
|
import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsence
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsenceType
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.teams.Team
|
import pl.szczodrzynski.edziennik.data.db.modules.teams.Team
|
||||||
import pl.szczodrzynski.edziennik.singleOrNull
|
import pl.szczodrzynski.edziennik.singleOrNull
|
||||||
import pl.szczodrzynski.edziennik.toSparseArray
|
import pl.szczodrzynski.edziennik.toSparseArray
|
||||||
@ -102,6 +103,7 @@ open class Data(val app: App, val profile: Profile?, val loginStore: LoginStore)
|
|||||||
val lessonRanges = SparseArray<LessonRange>()
|
val lessonRanges = SparseArray<LessonRange>()
|
||||||
val gradeCategories = LongSparseArray<GradeCategory>()
|
val gradeCategories = LongSparseArray<GradeCategory>()
|
||||||
val attendanceTypes = SparseArray<Pair<Int, String>>()
|
val attendanceTypes = SparseArray<Pair<Int, String>>()
|
||||||
|
val teacherAbsenceTypes = LongSparseArray<TeacherAbsenceType>()
|
||||||
|
|
||||||
private var mTeamClass: Team? = null
|
private var mTeamClass: Team? = null
|
||||||
var teamClass: Team?
|
var teamClass: Team?
|
||||||
@ -156,6 +158,7 @@ open class Data(val app: App, val profile: Profile?, val loginStore: LoginStore)
|
|||||||
db.teamDao().getAllNow(profileId).toSparseArray(teamList) { it.id }
|
db.teamDao().getAllNow(profileId).toSparseArray(teamList) { it.id }
|
||||||
db.lessonRangeDao().getAllNow(profileId).toSparseArray(lessonRanges) { it.lessonNumber }
|
db.lessonRangeDao().getAllNow(profileId).toSparseArray(lessonRanges) { it.lessonNumber }
|
||||||
db.gradeCategoryDao().getAllNow(profileId).toSparseArray(gradeCategories) { it.categoryId }
|
db.gradeCategoryDao().getAllNow(profileId).toSparseArray(gradeCategories) { it.categoryId }
|
||||||
|
db.teacherAbsenceTypeDao().getAllNow(profileId).toSparseArray(teacherAbsenceTypes) { it.id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,6 +208,8 @@ open class Data(val app: App, val profile: Profile?, val loginStore: LoginStore)
|
|||||||
db.lessonRangeDao().addAll(lessonRanges.values())
|
db.lessonRangeDao().addAll(lessonRanges.values())
|
||||||
db.gradeCategoryDao().clear(profileId)
|
db.gradeCategoryDao().clear(profileId)
|
||||||
db.gradeCategoryDao().addAll(gradeCategories.values())
|
db.gradeCategoryDao().addAll(gradeCategories.values())
|
||||||
|
db.teacherAbsenceTypeDao().clear(profileId)
|
||||||
|
db.teacherAbsenceTypeDao().addAll(teacherAbsenceTypes.values())
|
||||||
|
|
||||||
gradesToRemove?.let { it ->
|
gradesToRemove?.let { it ->
|
||||||
it.removeAll?.let { _ -> db.gradeDao().clear(profileId) }
|
it.removeAll?.let { _ -> db.gradeDao().clear(profileId) }
|
||||||
@ -297,8 +302,11 @@ open class Data(val app: App, val profile: Profile?, val loginStore: LoginStore)
|
|||||||
else -> errorCode
|
else -> errorCode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error(ApiError(tag, code).apply { profileId = profile?.id ?: -1 }.withResponse(response).withThrowable(throwable).withApiResponse(apiResponse))
|
error(ApiError(tag, code).apply {
|
||||||
|
profileId = profile?.id ?: -1
|
||||||
|
}.withResponse(response).withThrowable(throwable).withApiResponse(apiResponse))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun error(tag: String, errorCode: Int, response: Response? = null, apiResponse: String? = null) {
|
fun error(tag: String, errorCode: Int, response: Response? = null, apiResponse: String? = null) {
|
||||||
val code = when (null) {
|
val code = when (null) {
|
||||||
is UnknownHostException, is SSLException, is InterruptedIOException -> CODE_NO_INTERNET
|
is UnknownHostException, is SSLException, is InterruptedIOException -> CODE_NO_INTERNET
|
||||||
@ -308,16 +316,21 @@ open class Data(val app: App, val profile: Profile?, val loginStore: LoginStore)
|
|||||||
else -> errorCode
|
else -> errorCode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error(ApiError(tag, code).apply { profileId = profile?.id ?: -1 }.withResponse(response).withApiResponse(apiResponse))
|
error(ApiError(tag, code).apply {
|
||||||
|
profileId = profile?.id ?: -1
|
||||||
|
}.withResponse(response).withApiResponse(apiResponse))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun error(apiError: ApiError) {
|
fun error(apiError: ApiError) {
|
||||||
if (apiError.isCritical)
|
if (apiError.isCritical)
|
||||||
cancel()
|
cancel()
|
||||||
callback.onError(apiError)
|
callback.onError(apiError)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun progress(step: Int) {
|
fun progress(step: Int) {
|
||||||
callback.onProgress(step)
|
callback.onProgress(step)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startProgress(stringRes: Int) {
|
fun startProgress(stringRes: Int) {
|
||||||
callback.onStartProgress(stringRes)
|
callback.onStartProgress(stringRes)
|
||||||
}
|
}
|
||||||
|
@ -3201,6 +3201,7 @@ public class Librus implements EdziennikInterface {
|
|||||||
id,
|
id,
|
||||||
teacherId,
|
teacherId,
|
||||||
type,
|
type,
|
||||||
|
null,
|
||||||
dateFrom,
|
dateFrom,
|
||||||
dateTo,
|
dateTo,
|
||||||
timeFrom,
|
timeFrom,
|
||||||
|
@ -61,6 +61,8 @@ import pl.szczodrzynski.edziennik.data.db.modules.subjects.SubjectDao;
|
|||||||
import pl.szczodrzynski.edziennik.data.db.modules.teachers.Teacher;
|
import pl.szczodrzynski.edziennik.data.db.modules.teachers.Teacher;
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsence;
|
import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsence;
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsenceDao;
|
import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsenceDao;
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsenceType;
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherAbsenceTypeDao;
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherDao;
|
import pl.szczodrzynski.edziennik.data.db.modules.teachers.TeacherDao;
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.teams.Team;
|
import pl.szczodrzynski.edziennik.data.db.modules.teams.Team;
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.teams.TeamDao;
|
import pl.szczodrzynski.edziennik.data.db.modules.teams.TeamDao;
|
||||||
@ -71,6 +73,7 @@ import pl.szczodrzynski.edziennik.utils.models.Date;
|
|||||||
//GradeCategory.class,
|
//GradeCategory.class,
|
||||||
Teacher.class,
|
Teacher.class,
|
||||||
TeacherAbsence.class,
|
TeacherAbsence.class,
|
||||||
|
TeacherAbsenceType.class,
|
||||||
Subject.class,
|
Subject.class,
|
||||||
Notice.class,
|
Notice.class,
|
||||||
Lesson.class,
|
Lesson.class,
|
||||||
@ -91,7 +94,7 @@ import pl.szczodrzynski.edziennik.utils.models.Date;
|
|||||||
EndpointTimer.class,
|
EndpointTimer.class,
|
||||||
LessonRange.class,
|
LessonRange.class,
|
||||||
Notification.class,
|
Notification.class,
|
||||||
Metadata.class}, version = 60)
|
Metadata.class}, version = 61)
|
||||||
@TypeConverters({
|
@TypeConverters({
|
||||||
ConverterTime.class,
|
ConverterTime.class,
|
||||||
ConverterDate.class,
|
ConverterDate.class,
|
||||||
@ -105,6 +108,7 @@ public abstract class AppDb extends RoomDatabase {
|
|||||||
//public abstract GradeCategoryDao gradeCategoryDao();
|
//public abstract GradeCategoryDao gradeCategoryDao();
|
||||||
public abstract TeacherDao teacherDao();
|
public abstract TeacherDao teacherDao();
|
||||||
public abstract TeacherAbsenceDao teacherAbsenceDao();
|
public abstract TeacherAbsenceDao teacherAbsenceDao();
|
||||||
|
public abstract TeacherAbsenceTypeDao teacherAbsenceTypeDao();
|
||||||
public abstract SubjectDao subjectDao();
|
public abstract SubjectDao subjectDao();
|
||||||
public abstract NoticeDao noticeDao();
|
public abstract NoticeDao noticeDao();
|
||||||
public abstract LessonDao lessonDao();
|
public abstract LessonDao lessonDao();
|
||||||
@ -667,6 +671,17 @@ public abstract class AppDb extends RoomDatabase {
|
|||||||
database.execSQL("ALTER TABLE profiles ADD COLUMN disabledNotifications TEXT DEFAULT NULL");
|
database.execSQL("ALTER TABLE profiles ADD COLUMN disabledNotifications TEXT DEFAULT NULL");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private static final Migration MIGRATION_60_61 = new Migration(60, 61) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
database.execSQL("CREATE TABLE IF NOT EXISTS teacherAbsenceTypes (" +
|
||||||
|
"profileId INTEGER NOT NULL," +
|
||||||
|
"teacherAbsenceTypeId INTEGER NOT NULL," +
|
||||||
|
"teacherAbsenceTypeName TEXT NOT NULL," +
|
||||||
|
"PRIMARY KEY(profileId, teacherAbsenceTypeId))");
|
||||||
|
database.execSQL("ALTER TABLE teacherAbsence ADD COLUMN teacherAbsenceName TEXT DEFAULT NULL");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
public static AppDb getDatabase(final Context context) {
|
public static AppDb getDatabase(final Context context) {
|
||||||
@ -724,7 +739,8 @@ public abstract class AppDb extends RoomDatabase {
|
|||||||
MIGRATION_56_57,
|
MIGRATION_56_57,
|
||||||
MIGRATION_57_58,
|
MIGRATION_57_58,
|
||||||
MIGRATION_58_59,
|
MIGRATION_58_59,
|
||||||
MIGRATION_59_60
|
MIGRATION_59_60,
|
||||||
|
MIGRATION_60_61
|
||||||
)
|
)
|
||||||
.allowMainThreadQueries()
|
.allowMainThreadQueries()
|
||||||
//.fallbackToDestructiveMigration()
|
//.fallbackToDestructiveMigration()
|
||||||
|
@ -19,6 +19,9 @@ open class TeacherAbsence (
|
|||||||
@ColumnInfo(name = "teacherAbsenceType")
|
@ColumnInfo(name = "teacherAbsenceType")
|
||||||
val type: Long,
|
val type: Long,
|
||||||
|
|
||||||
|
@ColumnInfo(name = "teacherAbsenceName")
|
||||||
|
val name: String?,
|
||||||
|
|
||||||
@ColumnInfo(name = "teacherAbsenceDateFrom")
|
@ColumnInfo(name = "teacherAbsenceDateFrom")
|
||||||
val dateFrom: Date,
|
val dateFrom: Date,
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@ 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
|
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||||
|
|
||||||
class TeacherAbsenceFull(profileId: Int, id: Long, teacherId: Long, type: Long,
|
class TeacherAbsenceFull(profileId: Int, id: Long, teacherId: Long, type: Long, name: String?,
|
||||||
dateFrom: Date, dateTo: Date, timeFrom: Time?, timeTo: Time?)
|
dateFrom: Date, dateTo: Date, timeFrom: Time?, timeTo: Time?)
|
||||||
: TeacherAbsence(profileId, id, teacherId, type, dateFrom, dateTo, timeFrom, timeTo) {
|
: TeacherAbsence(profileId, id, teacherId, type, name, dateFrom, dateTo, timeFrom, timeTo) {
|
||||||
|
|
||||||
var teacherFullName = ""
|
var teacherFullName = ""
|
||||||
|
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2019-10-18
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.db.modules.teachers
|
||||||
|
|
||||||
|
import androidx.room.ColumnInfo
|
||||||
|
import androidx.room.Entity
|
||||||
|
|
||||||
|
@Entity(tableName = "teacherAbsenceTypes",
|
||||||
|
primaryKeys = ["profileId", "teacherAbsenceTypeId"])
|
||||||
|
data class TeacherAbsenceType (
|
||||||
|
val profileId: Int,
|
||||||
|
|
||||||
|
@ColumnInfo(name = "teacherAbsenceTypeId")
|
||||||
|
val id: Long,
|
||||||
|
|
||||||
|
@ColumnInfo(name = "teacherAbsenceTypeName")
|
||||||
|
val name: String
|
||||||
|
)
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2019-10-18
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.db.modules.teachers
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.OnConflictStrategy
|
||||||
|
import androidx.room.Query
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface TeacherAbsenceTypeDao {
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
fun add(teacherAbsence: TeacherAbsenceType)
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
fun addAll(teacherAbsenceList: List<TeacherAbsenceType>)
|
||||||
|
|
||||||
|
@Query("DELETE FROM teacherAbsenceTypes WHERE profileId = :profileId")
|
||||||
|
fun clear(profileId: Int)
|
||||||
|
|
||||||
|
@Query("SELECT * FROM teacherAbsenceTypes WHERE profileId = :profileId")
|
||||||
|
fun getAllNow(profileId: Int): List<TeacherAbsenceType>
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package pl.szczodrzynski.edziennik.ui.dialogs.teacherabsence
|
package pl.szczodrzynski.edziennik.ui.dialogs.teacherabsence
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.opengl.Visibility
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@ -47,10 +48,19 @@ class TeacherAbsenceAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
holder.teacherAbsenceTime.text = time
|
holder.teacherAbsenceTime.text = time
|
||||||
|
|
||||||
|
if (teacherAbsence.name != null) {
|
||||||
|
holder.teacherAbsenceName.visibility = View.VISIBLE
|
||||||
|
holder.teacherAbsenceName.text = teacherAbsence.name
|
||||||
|
} else {
|
||||||
|
holder.teacherAbsenceName.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
var teacherAbsenceTeacher: TextView = itemView.findViewById(R.id.teacherAbsenceTeacher)
|
var teacherAbsenceTeacher: TextView = itemView.findViewById(R.id.teacherAbsenceTeacher)
|
||||||
var teacherAbsenceTime: TextView = itemView.findViewById(R.id.teacherAbsenceTime)
|
var teacherAbsenceTime: TextView = itemView.findViewById(R.id.teacherAbsenceTime)
|
||||||
|
var teacherAbsenceName: TextView = itemView.findViewById(R.id.teacherAbsenceName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,15 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:text="Jan Kowalski"/>
|
tools:text="Jan Kowalski"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/teacherAbsenceName"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@style/NavView.TextView.Helper"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:text="wycieczka"
|
||||||
|
tools:visibility="visible"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -949,4 +949,5 @@
|
|||||||
<string name="edziennik_notification_api_first_login_title">Pierwsze logowanie</string>
|
<string name="edziennik_notification_api_first_login_title">Pierwsze logowanie</string>
|
||||||
<string name="edziennik_progress_endpoint_classes">Pobieranie informacji o klasie...</string>
|
<string name="edziennik_progress_endpoint_classes">Pobieranie informacji o klasie...</string>
|
||||||
<string name="edziennik_progress_endpoint_teacher_free_days">Pobieranie nieobecności nauczycieli...</string>
|
<string name="edziennik_progress_endpoint_teacher_free_days">Pobieranie nieobecności nauczycieli...</string>
|
||||||
|
<string name="edziennik_progress_endpoint_teacher_free_day_types">Pobieranie rodzajów nieobecności nauczycieli...</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user