mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-18 13:36:47 -06:00
Add school info (#557)
* Add db layer to school info * Add base classes * Add database migration * Add base view * Update icon * Fix textviews height * Handle error and empty results * Improve school info look * Add strings * Fix action bar elevation in school fragment * Add missing blank lines * Reorganize strings * Make field title first in order * Make fields views selectable * Rename SchoolInfo to School
This commit is contained in:
parent
1b492d50fe
commit
7a4cf694ca
1592
app/schemas/io.github.wulkanowy.data.db.AppDatabase/18.json
Normal file
1592
app/schemas/io.github.wulkanowy.data.db.AppDatabase/18.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -144,4 +144,8 @@ internal class RepositoryModule {
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideTeacherDao(database: AppDatabase) = database.teacherDao
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideSchoolInfoDao(database: AppDatabase) = database.schoolDao
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import io.github.wulkanowy.data.db.dao.MobileDeviceDao
|
||||
import io.github.wulkanowy.data.db.dao.NoteDao
|
||||
import io.github.wulkanowy.data.db.dao.RecipientDao
|
||||
import io.github.wulkanowy.data.db.dao.ReportingUnitDao
|
||||
import io.github.wulkanowy.data.db.dao.SchoolDao
|
||||
import io.github.wulkanowy.data.db.dao.SemesterDao
|
||||
import io.github.wulkanowy.data.db.dao.StudentDao
|
||||
import io.github.wulkanowy.data.db.dao.SubjectDao
|
||||
@ -42,6 +43,7 @@ import io.github.wulkanowy.data.db.entities.MobileDevice
|
||||
import io.github.wulkanowy.data.db.entities.Note
|
||||
import io.github.wulkanowy.data.db.entities.Recipient
|
||||
import io.github.wulkanowy.data.db.entities.ReportingUnit
|
||||
import io.github.wulkanowy.data.db.entities.School
|
||||
import io.github.wulkanowy.data.db.entities.Semester
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.data.db.entities.Subject
|
||||
@ -55,6 +57,7 @@ import io.github.wulkanowy.data.db.migrations.Migration14
|
||||
import io.github.wulkanowy.data.db.migrations.Migration15
|
||||
import io.github.wulkanowy.data.db.migrations.Migration16
|
||||
import io.github.wulkanowy.data.db.migrations.Migration17
|
||||
import io.github.wulkanowy.data.db.migrations.Migration18
|
||||
import io.github.wulkanowy.data.db.migrations.Migration2
|
||||
import io.github.wulkanowy.data.db.migrations.Migration3
|
||||
import io.github.wulkanowy.data.db.migrations.Migration4
|
||||
@ -87,7 +90,8 @@ import javax.inject.Singleton
|
||||
ReportingUnit::class,
|
||||
Recipient::class,
|
||||
MobileDevice::class,
|
||||
Teacher::class
|
||||
Teacher::class,
|
||||
School::class
|
||||
],
|
||||
version = AppDatabase.VERSION_SCHEMA,
|
||||
exportSchema = true
|
||||
@ -96,7 +100,7 @@ import javax.inject.Singleton
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
companion object {
|
||||
const val VERSION_SCHEMA = 17
|
||||
const val VERSION_SCHEMA = 18
|
||||
|
||||
fun getMigrations(): Array<Migration> {
|
||||
return arrayOf(
|
||||
@ -115,7 +119,8 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
Migration14(),
|
||||
Migration15(),
|
||||
Migration16(),
|
||||
Migration17()
|
||||
Migration17(),
|
||||
Migration18()
|
||||
)
|
||||
}
|
||||
|
||||
@ -168,4 +173,6 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
abstract val mobileDeviceDao: MobileDeviceDao
|
||||
|
||||
abstract val teacherDao: TeacherDao
|
||||
|
||||
abstract val schoolDao: SchoolDao
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package io.github.wulkanowy.data.db.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.Query
|
||||
import io.github.wulkanowy.data.db.entities.School
|
||||
import io.reactivex.Maybe
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
@Dao
|
||||
interface SchoolDao {
|
||||
|
||||
@Insert
|
||||
fun insert(school: School)
|
||||
|
||||
@Delete
|
||||
fun delete(school: School)
|
||||
|
||||
@Query("SELECT * FROM School WHERE student_id = :studentId AND class_id = :classId")
|
||||
fun load(studentId: Int, classId: Int): Maybe<School>
|
||||
}
|
@ -13,10 +13,10 @@ import javax.inject.Singleton
|
||||
interface TeacherDao {
|
||||
|
||||
@Insert
|
||||
fun insertAll(devices: List<Teacher>)
|
||||
fun insertAll(teachers: List<Teacher>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(devices: List<Teacher>)
|
||||
fun deleteAll(teachers: List<Teacher>)
|
||||
|
||||
@Query("SELECT * FROM Teachers WHERE student_id = :studentId AND class_id = :classId")
|
||||
fun loadAll(studentId: Int, classId: Int): Maybe<List<Teacher>>
|
||||
|
@ -0,0 +1,30 @@
|
||||
package io.github.wulkanowy.data.db.entities
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import java.io.Serializable
|
||||
|
||||
@Entity(tableName = "School")
|
||||
data class School(
|
||||
|
||||
@ColumnInfo(name = "student_id")
|
||||
val studentId: Int,
|
||||
|
||||
@ColumnInfo(name = "class_id")
|
||||
val classId: Int,
|
||||
|
||||
val name: String,
|
||||
|
||||
val address: String,
|
||||
|
||||
val contact: String,
|
||||
|
||||
val headmaster: String,
|
||||
|
||||
val pedagogue: String
|
||||
) : Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
var id: Long = 0
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package io.github.wulkanowy.data.db.migrations
|
||||
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
|
||||
class Migration18 : Migration(17, 18) {
|
||||
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("""
|
||||
CREATE TABLE IF NOT EXISTS School (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
student_id INTEGER NOT NULL,
|
||||
class_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
address TEXT NOT NULL,
|
||||
contact TEXT NOT NULL,
|
||||
headmaster TEXT NOT NULL,
|
||||
pedagogue TEXT NOT NULL
|
||||
)
|
||||
""")
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package io.github.wulkanowy.data.repositories.school
|
||||
|
||||
import io.github.wulkanowy.data.db.dao.SchoolDao
|
||||
import io.github.wulkanowy.data.db.entities.School
|
||||
import io.github.wulkanowy.data.db.entities.Semester
|
||||
import io.reactivex.Maybe
|
||||
import javax.inject.Inject
|
||||
|
||||
class SchoolLocal @Inject constructor(private val schoolDb: SchoolDao) {
|
||||
|
||||
fun saveSchool(school: School) {
|
||||
schoolDb.insert(school)
|
||||
}
|
||||
|
||||
fun deleteSchool(school: School) {
|
||||
schoolDb.delete(school)
|
||||
}
|
||||
|
||||
fun getSchool(semester: Semester): Maybe<School> {
|
||||
return schoolDb.load(semester.studentId, semester.classId)
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package io.github.wulkanowy.data.repositories.school
|
||||
|
||||
import io.github.wulkanowy.api.Api
|
||||
import io.github.wulkanowy.data.db.entities.School
|
||||
import io.github.wulkanowy.data.db.entities.Semester
|
||||
import io.reactivex.Single
|
||||
import javax.inject.Inject
|
||||
|
||||
class SchoolRemote @Inject constructor(private val api: Api) {
|
||||
|
||||
fun getSchoolInfo(semester: Semester): Single<School> {
|
||||
return Single.just(api.apply { diaryId = semester.diaryId })
|
||||
.flatMap { it.getSchool() }
|
||||
.map {
|
||||
School(
|
||||
studentId = semester.studentId,
|
||||
classId = semester.classId,
|
||||
name = it.name,
|
||||
address = it.address,
|
||||
contact = it.contact,
|
||||
headmaster = it.headmaster,
|
||||
pedagogue = it.pedagogue
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package io.github.wulkanowy.data.repositories.school
|
||||
|
||||
import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork
|
||||
import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.InternetObservingSettings
|
||||
import io.github.wulkanowy.data.db.entities.School
|
||||
import io.github.wulkanowy.data.db.entities.Semester
|
||||
import io.reactivex.Maybe
|
||||
import io.reactivex.Single
|
||||
import java.net.UnknownHostException
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class SchoolRepository @Inject constructor(
|
||||
private val settings: InternetObservingSettings,
|
||||
private val local: SchoolLocal,
|
||||
private val remote: SchoolRemote
|
||||
) {
|
||||
|
||||
fun getSchoolInfo(semester: Semester, forceRefresh: Boolean = false): Maybe<School> {
|
||||
return local.getSchool(semester).filter { !forceRefresh }
|
||||
.switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings)
|
||||
.flatMap {
|
||||
if (it) remote.getSchoolInfo(semester)
|
||||
else Single.error(UnknownHostException())
|
||||
}.flatMapMaybe { new ->
|
||||
local.getSchool(semester)
|
||||
.doOnSuccess { old ->
|
||||
if (new != old) {
|
||||
local.deleteSchool(old)
|
||||
local.saveSchool(new)
|
||||
}
|
||||
}
|
||||
.doOnComplete {
|
||||
local.saveSchool(new)
|
||||
}
|
||||
}.flatMap({ local.getSchool(semester) }, { Maybe.error(it) },
|
||||
{ local.getSchool(semester) })
|
||||
)
|
||||
}
|
||||
}
|
@ -6,7 +6,8 @@ import io.github.wulkanowy.data.db.entities.Teacher
|
||||
import io.reactivex.Maybe
|
||||
import javax.inject.Inject
|
||||
|
||||
class TeacherLocal @Inject constructor(private val teacherDb: TeacherDao) {
|
||||
class TeacherLocal @Inject constructor(private val teacherDb: TeacherDao) {
|
||||
|
||||
fun saveTeachers(teachers: List<Teacher>) {
|
||||
teacherDb.insertAll(teachers)
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ class TeacherRepository @Inject constructor(
|
||||
private val local: TeacherLocal,
|
||||
private val remote: TeacherRemote
|
||||
) {
|
||||
|
||||
fun getTeachers(semester: Semester, forceRefresh: Boolean = false): Single<List<Teacher>> {
|
||||
return local.getTeachers(semester).filter { !forceRefresh }
|
||||
.switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings)
|
||||
|
@ -26,8 +26,10 @@ import io.github.wulkanowy.ui.modules.mobiledevice.MobileDeviceModule
|
||||
import io.github.wulkanowy.ui.modules.mobiledevice.token.MobileDeviceTokenDialog
|
||||
import io.github.wulkanowy.ui.modules.more.MoreFragment
|
||||
import io.github.wulkanowy.ui.modules.note.NoteFragment
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragment
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersModule
|
||||
import io.github.wulkanowy.ui.modules.settings.SettingsFragment
|
||||
import io.github.wulkanowy.ui.modules.teacher.TeacherFragment
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.teacher.TeacherFragment
|
||||
import io.github.wulkanowy.ui.modules.timetable.TimetableFragment
|
||||
import io.github.wulkanowy.ui.modules.timetable.completed.CompletedLessonsFragment
|
||||
|
||||
@ -123,6 +125,6 @@ abstract class MainModule {
|
||||
abstract fun bindLicenseFragment(): LicenseFragment
|
||||
|
||||
@PerFragment
|
||||
@ContributesAndroidInjector
|
||||
abstract fun bindTeacherFragment(): TeacherFragment
|
||||
@ContributesAndroidInjector(modules = [SchoolAndTeachersModule::class])
|
||||
abstract fun bindSchoolAndTeachersFragment(): SchoolAndTeachersFragment
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.ui.modules.main.MainView.Section.GRADE
|
||||
import io.github.wulkanowy.ui.modules.main.MainView.Section.MESSAGE
|
||||
import io.github.wulkanowy.ui.modules.main.MainView.Section.SCHOOL
|
||||
import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
||||
import io.github.wulkanowy.utils.SchedulersProvider
|
||||
import timber.log.Timber
|
||||
@ -38,7 +39,7 @@ class MainPresenter @Inject constructor(
|
||||
|
||||
fun onViewChange(section: MainView.Section?) {
|
||||
view?.apply {
|
||||
showActionBarElevation(section != GRADE && section != MESSAGE)
|
||||
showActionBarElevation(section != GRADE && section != MESSAGE && section != SCHOOL)
|
||||
currentViewTitle?.let { setViewTitle(it) }
|
||||
currentStackSize?.let {
|
||||
if (it > 1) showHomeArrow(true)
|
||||
|
@ -51,6 +51,7 @@ interface MainView : BaseView {
|
||||
NOTE(7),
|
||||
LUCKY_NUMBER(8),
|
||||
SETTINGS(9),
|
||||
ABOUT(10)
|
||||
ABOUT(10),
|
||||
SCHOOL(11)
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,9 @@ import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.ui.modules.message.MessageFragment
|
||||
import io.github.wulkanowy.ui.modules.mobiledevice.MobileDeviceFragment
|
||||
import io.github.wulkanowy.ui.modules.note.NoteFragment
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragment
|
||||
import io.github.wulkanowy.ui.modules.settings.SettingsFragment
|
||||
import io.github.wulkanowy.ui.modules.teacher.TeacherFragment
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.teacher.TeacherFragment
|
||||
import io.github.wulkanowy.utils.getCompatDrawable
|
||||
import io.github.wulkanowy.utils.setOnItemClickListener
|
||||
import kotlinx.android.synthetic.main.fragment_more.*
|
||||
@ -55,8 +56,8 @@ class MoreFragment : BaseFragment(), MoreView, MainView.TitledView, MainView.Mai
|
||||
override val mobileDevicesRes: Pair<String, Drawable?>?
|
||||
get() = context?.run { getString(R.string.mobile_devices_title) to getCompatDrawable(R.drawable.ic_more_mobile_devices) }
|
||||
|
||||
override val teachersRes: Pair<String, Drawable?>?
|
||||
get() = context?.run { getString(R.string.teachers_title) to getCompatDrawable((R.drawable.ic_more_teacher)) }
|
||||
override val schoolAndTeachersRes: Pair<String, Drawable?>?
|
||||
get() = context?.run { getString(R.string.schoolandteachers_title) to getCompatDrawable((R.drawable.ic_more_schoolandteachers)) }
|
||||
|
||||
override val settingsRes: Pair<String, Drawable?>?
|
||||
get() = context?.run { getString(R.string.settings_title) to getCompatDrawable(R.drawable.ic_more_settings) }
|
||||
@ -110,8 +111,8 @@ class MoreFragment : BaseFragment(), MoreView, MainView.TitledView, MainView.Mai
|
||||
(activity as? MainActivity)?.pushView(MobileDeviceFragment.newInstance())
|
||||
}
|
||||
|
||||
override fun openTeachersView() {
|
||||
(activity as? MainActivity)?.pushView(TeacherFragment.newInstance())
|
||||
override fun openSchoolAndTeachersView() {
|
||||
(activity as? MainActivity)?.pushView(SchoolAndTeachersFragment.newInstance())
|
||||
}
|
||||
|
||||
override fun openSettingsView() {
|
||||
|
@ -31,7 +31,7 @@ class MorePresenter @Inject constructor(
|
||||
noteRes?.first -> openNoteView()
|
||||
luckyNumberRes?.first -> openLuckyNumberView()
|
||||
mobileDevicesRes?.first -> openMobileDevicesView()
|
||||
teachersRes?.first -> openTeachersView()
|
||||
schoolAndTeachersRes?.first -> openSchoolAndTeachersView()
|
||||
settingsRes?.first -> openSettingsView()
|
||||
aboutRes?.first -> openAboutView()
|
||||
}
|
||||
@ -52,7 +52,7 @@ class MorePresenter @Inject constructor(
|
||||
noteRes?.let { MoreItem(it.first, it.second) },
|
||||
luckyNumberRes?.let { MoreItem(it.first, it.second) },
|
||||
mobileDevicesRes?.let { MoreItem(it.first, it.second) },
|
||||
teachersRes?.let { MoreItem(it.first, it.second) },
|
||||
schoolAndTeachersRes?.let { MoreItem(it.first, it.second) },
|
||||
settingsRes?.let { MoreItem(it.first, it.second) },
|
||||
aboutRes?.let { MoreItem(it.first, it.second) })
|
||||
)
|
||||
|
@ -15,7 +15,7 @@ interface MoreView : BaseView {
|
||||
|
||||
val mobileDevicesRes: Pair<String, Drawable?>?
|
||||
|
||||
val teachersRes: Pair<String, Drawable?>?
|
||||
val schoolAndTeachersRes: Pair<String, Drawable?>?
|
||||
|
||||
val settingsRes: Pair<String, Drawable?>?
|
||||
|
||||
@ -41,5 +41,5 @@ interface MoreView : BaseView {
|
||||
|
||||
fun openMobileDevicesView()
|
||||
|
||||
fun openTeachersView()
|
||||
fun openSchoolAndTeachersView()
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
package io.github.wulkanowy.ui.modules.schoolandteachers
|
||||
|
||||
interface SchoolAndTeachersChildView {
|
||||
|
||||
fun notifyParentDataLoaded()
|
||||
|
||||
fun onParentLoadData(forceRefresh: Boolean)
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package io.github.wulkanowy.ui.modules.schoolandteachers
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.View.INVISIBLE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.school.SchoolFragment
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.teacher.TeacherFragment
|
||||
import io.github.wulkanowy.utils.dpToPx
|
||||
import io.github.wulkanowy.utils.setOnSelectPageListener
|
||||
import kotlinx.android.synthetic.main.fragment_schoolandteachers.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class SchoolAndTeachersFragment : BaseFragment(), SchoolAndTeachersView, MainView.TitledView {
|
||||
|
||||
@Inject
|
||||
lateinit var presenter: SchoolAndTeachersPresenter
|
||||
|
||||
@Inject
|
||||
lateinit var pagerAdapter: BaseFragmentPagerAdapter
|
||||
|
||||
companion object {
|
||||
fun newInstance() = SchoolAndTeachersFragment()
|
||||
}
|
||||
|
||||
override val titleStringId: Int get() = R.string.schoolandteachers_title
|
||||
|
||||
override val currentPageIndex get() = schoolandteachersViewPager.currentItem
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_schoolandteachers, container, false)
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
presenter.onAttachView(this)
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
with(pagerAdapter) {
|
||||
containerId = schoolandteachersViewPager.id
|
||||
addFragmentsWithTitle(mapOf(
|
||||
SchoolFragment.newInstance() to getString(R.string.school_title),
|
||||
TeacherFragment.newInstance() to getString(R.string.teachers_title)
|
||||
))
|
||||
}
|
||||
|
||||
with(schoolandteachersViewPager) {
|
||||
adapter = pagerAdapter
|
||||
offscreenPageLimit = 2
|
||||
setOnSelectPageListener(presenter::onPageSelected)
|
||||
}
|
||||
|
||||
with(schoolandteachersTabLayout) {
|
||||
setupWithViewPager(schoolandteachersViewPager)
|
||||
setElevationCompat(context.dpToPx(4f))
|
||||
}
|
||||
}
|
||||
|
||||
override fun showContent(show: Boolean) {
|
||||
schoolandteachersViewPager.visibility = if (show) VISIBLE else INVISIBLE
|
||||
schoolandteachersTabLayout.visibility = if (show) VISIBLE else INVISIBLE
|
||||
}
|
||||
|
||||
override fun showProgress(show: Boolean) {
|
||||
schoolandteachersProgress.visibility = if (show) VISIBLE else INVISIBLE
|
||||
}
|
||||
|
||||
fun onChildFragmentLoaded() {
|
||||
presenter.onChildViewLoaded()
|
||||
}
|
||||
|
||||
override fun notifyChildLoadData(index: Int, forceRefresh: Boolean) {
|
||||
(pagerAdapter.getFragmentInstance(index) as? SchoolAndTeachersChildView)?.onParentLoadData(forceRefresh)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
presenter.onDetachView()
|
||||
super.onDestroyView()
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package io.github.wulkanowy.ui.modules.schoolandteachers
|
||||
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.android.ContributesAndroidInjector
|
||||
import io.github.wulkanowy.di.scopes.PerChildFragment
|
||||
import io.github.wulkanowy.di.scopes.PerFragment
|
||||
import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.school.SchoolFragment
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.teacher.TeacherFragment
|
||||
|
||||
@Suppress("unused")
|
||||
@Module
|
||||
abstract class SchoolAndTeachersModule {
|
||||
|
||||
@Module
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
@PerFragment
|
||||
@Provides
|
||||
fun provideSchoolAndTeachersAdapter(fragment: SchoolAndTeachersFragment) = BaseFragmentPagerAdapter(fragment.childFragmentManager)
|
||||
}
|
||||
|
||||
@PerChildFragment
|
||||
@ContributesAndroidInjector
|
||||
abstract fun provideSchoolFragment(): SchoolFragment
|
||||
|
||||
@PerChildFragment
|
||||
@ContributesAndroidInjector
|
||||
abstract fun provideTeacherFragment(): TeacherFragment
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package io.github.wulkanowy.ui.modules.schoolandteachers
|
||||
|
||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.utils.SchedulersProvider
|
||||
import io.reactivex.Completable
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
class SchoolAndTeachersPresenter @Inject constructor(
|
||||
schedulers: SchedulersProvider,
|
||||
errorHandler: ErrorHandler,
|
||||
studentRepository: StudentRepository
|
||||
) : BasePresenter<SchoolAndTeachersView>(errorHandler, studentRepository, schedulers) {
|
||||
|
||||
override fun onAttachView(view: SchoolAndTeachersView) {
|
||||
super.onAttachView(view)
|
||||
disposable.add(Completable.timer(150, TimeUnit.MILLISECONDS, schedulers.mainThread)
|
||||
.subscribe {
|
||||
view.initView()
|
||||
Timber.i("Message view was initialized")
|
||||
loadData()
|
||||
})
|
||||
}
|
||||
|
||||
fun onPageSelected(index: Int) {
|
||||
loadChild(index)
|
||||
}
|
||||
|
||||
private fun loadData() {
|
||||
view?.run { loadChild(currentPageIndex) }
|
||||
}
|
||||
|
||||
private fun loadChild(index: Int, forceRefresh: Boolean = false) {
|
||||
Timber.i("Load schoolandteachers child view index: $index")
|
||||
view?.notifyChildLoadData(index, forceRefresh)
|
||||
}
|
||||
|
||||
fun onChildViewLoaded() {
|
||||
view?.apply {
|
||||
showContent(true)
|
||||
showProgress(false)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package io.github.wulkanowy.ui.modules.schoolandteachers
|
||||
|
||||
import io.github.wulkanowy.ui.base.BaseView
|
||||
|
||||
interface SchoolAndTeachersView : BaseView {
|
||||
|
||||
val currentPageIndex: Int
|
||||
|
||||
fun initView()
|
||||
|
||||
fun showContent(show: Boolean)
|
||||
|
||||
fun showProgress(show: Boolean)
|
||||
|
||||
fun notifyChildLoadData(index: Int, forceRefresh: Boolean)
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package io.github.wulkanowy.ui.modules.schoolandteachers.school
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.School
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersChildView
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragment
|
||||
import kotlinx.android.synthetic.main.fragment_school.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class SchoolFragment : BaseFragment(), SchoolView, MainView.TitledView, SchoolAndTeachersChildView {
|
||||
|
||||
@Inject
|
||||
lateinit var presenter: SchoolPresenter
|
||||
|
||||
override val titleStringId get() = R.string.school_title
|
||||
|
||||
companion object {
|
||||
fun newInstance() = SchoolFragment()
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_school, container, false)
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
presenter.onAttachView(this)
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
schoolSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||
}
|
||||
|
||||
override fun updateData(data: School) {
|
||||
schoolName.text = data.name
|
||||
schoolAddress.text = data.address.ifBlank { "-" }
|
||||
schoolTelephone.text = data.contact.ifBlank { "-" }
|
||||
schoolHeadmaster.text = data.headmaster
|
||||
schoolPedagogue.text = data.pedagogue
|
||||
}
|
||||
|
||||
override fun showEmpty(show: Boolean) {
|
||||
schoolEmpty.visibility = if (show) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
override fun showProgress(show: Boolean) {
|
||||
schoolProgress.visibility = if (show) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
override fun enableSwipe(enable: Boolean) {
|
||||
schoolSwipe.isEnabled = enable
|
||||
}
|
||||
|
||||
override fun showContent(show: Boolean) {
|
||||
schoolContent.visibility = if (show) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
override fun hideRefresh() {
|
||||
schoolSwipe.isRefreshing = false
|
||||
}
|
||||
|
||||
override fun notifyParentDataLoaded() {
|
||||
(parentFragment as? SchoolAndTeachersFragment)?.onChildFragmentLoaded()
|
||||
}
|
||||
|
||||
override fun onParentLoadData(forceRefresh: Boolean) {
|
||||
presenter.onParentViewLoadData(forceRefresh)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
presenter.onDetachView()
|
||||
super.onDestroyView()
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package io.github.wulkanowy.ui.modules.schoolandteachers.school
|
||||
|
||||
import io.github.wulkanowy.data.repositories.school.SchoolRepository
|
||||
import io.github.wulkanowy.data.repositories.semester.SemesterRepository
|
||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
||||
import io.github.wulkanowy.utils.SchedulersProvider
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class SchoolPresenter @Inject constructor(
|
||||
schedulers: SchedulersProvider,
|
||||
errorHandler: ErrorHandler,
|
||||
studentRepository: StudentRepository,
|
||||
private val semesterRepository: SemesterRepository,
|
||||
private val schoolRepository: SchoolRepository,
|
||||
private val analytics: FirebaseAnalyticsHelper
|
||||
) : BasePresenter<SchoolView>(errorHandler, studentRepository, schedulers) {
|
||||
|
||||
override fun onAttachView(view: SchoolView) {
|
||||
super.onAttachView(view)
|
||||
view.initView()
|
||||
Timber.i("School view was initialized")
|
||||
loadData()
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
fun onParentViewLoadData(forceRefresh: Boolean) {
|
||||
loadData(forceRefresh)
|
||||
}
|
||||
|
||||
private fun loadData(forceRefresh: Boolean = false) {
|
||||
Timber.i("Loading school info started")
|
||||
disposable.add(studentRepository.getCurrentStudent()
|
||||
.flatMap { semesterRepository.getCurrentSemester(it) }
|
||||
.flatMapMaybe { schoolRepository.getSchoolInfo(it, forceRefresh) }
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
.doFinally {
|
||||
view?.run {
|
||||
hideRefresh()
|
||||
showProgress(false)
|
||||
enableSwipe(true)
|
||||
notifyParentDataLoaded()
|
||||
}
|
||||
}.subscribe({
|
||||
Timber.i("Loading teachers result: Success")
|
||||
view?.run {
|
||||
updateData(it)
|
||||
showContent(true)
|
||||
showEmpty(false)
|
||||
}
|
||||
analytics.logEvent("load_school", "force_refresh" to forceRefresh)
|
||||
}, {
|
||||
Timber.i("Loading school result: An exception occurred")
|
||||
errorHandler.dispatch(it)
|
||||
}, {
|
||||
Timber.i("Loading school result: No school info found")
|
||||
view?.run {
|
||||
showContent(false)
|
||||
showEmpty(true)
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package io.github.wulkanowy.ui.modules.schoolandteachers.school
|
||||
|
||||
import io.github.wulkanowy.data.db.entities.School
|
||||
import io.github.wulkanowy.ui.base.BaseView
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersChildView
|
||||
|
||||
interface SchoolView : BaseView, SchoolAndTeachersChildView {
|
||||
|
||||
fun initView()
|
||||
|
||||
fun updateData(data: School)
|
||||
|
||||
fun showEmpty(show: Boolean)
|
||||
|
||||
fun showProgress(show: Boolean)
|
||||
|
||||
fun enableSwipe(enable: Boolean)
|
||||
|
||||
fun showContent(show: Boolean)
|
||||
|
||||
fun hideRefresh()
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package io.github.wulkanowy.ui.modules.teacher
|
||||
package io.github.wulkanowy.ui.modules.schoolandteachers.teacher
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
@ -11,10 +11,13 @@ import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersChildView
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragment
|
||||
import kotlinx.android.synthetic.main.fragment_teacher.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class TeacherFragment : BaseFragment(), TeacherView, MainView.TitledView {
|
||||
class TeacherFragment : BaseFragment(), TeacherView, MainView.TitledView, SchoolAndTeachersChildView {
|
||||
|
||||
@Inject
|
||||
lateinit var presenter: TeacherPresenter
|
||||
|
||||
@ -86,6 +89,14 @@ class TeacherFragment : BaseFragment(), TeacherView, MainView.TitledView {
|
||||
teacherSwipe.isRefreshing = false
|
||||
}
|
||||
|
||||
override fun notifyParentDataLoaded() {
|
||||
(parentFragment as? SchoolAndTeachersFragment)?.onChildFragmentLoaded()
|
||||
}
|
||||
|
||||
override fun onParentLoadData(forceRefresh: Boolean) {
|
||||
presenter.onParentViewLoadData(forceRefresh)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
presenter.onDetachView()
|
||||
super.onDestroyView()
|
@ -1,4 +1,4 @@
|
||||
package io.github.wulkanowy.ui.modules.teacher
|
||||
package io.github.wulkanowy.ui.modules.schoolandteachers.teacher
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.View
|
@ -1,4 +1,4 @@
|
||||
package io.github.wulkanowy.ui.modules.teacher
|
||||
package io.github.wulkanowy.ui.modules.schoolandteachers.teacher
|
||||
|
||||
import io.github.wulkanowy.data.repositories.semester.SemesterRepository
|
||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||
@ -14,7 +14,6 @@ class TeacherPresenter @Inject constructor(
|
||||
schedulers: SchedulersProvider,
|
||||
errorHandler: ErrorHandler,
|
||||
studentRepository: StudentRepository,
|
||||
|
||||
private val semesterRepository: SemesterRepository,
|
||||
private val teacherRepository: TeacherRepository,
|
||||
private val analytics: FirebaseAnalyticsHelper
|
||||
@ -31,12 +30,16 @@ class TeacherPresenter @Inject constructor(
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
fun onParentViewLoadData(forceRefresh: Boolean) {
|
||||
loadData(forceRefresh)
|
||||
}
|
||||
|
||||
private fun loadData(forceRefresh: Boolean = false) {
|
||||
Timber.i("Loading teachers data started")
|
||||
disposable.add(studentRepository.getCurrentStudent()
|
||||
.flatMap { semesterRepository.getCurrentSemester(it) }
|
||||
.flatMap { teacherRepository.getTeachers(it, forceRefresh) }
|
||||
.map { it.filter { teacher -> teacher.name.isNotBlank() } }
|
||||
.map { it.filter { teacher -> teacher.name.isNotBlank() } }
|
||||
.map { items -> items.map { TeacherItem(it, view?.noSubjectString.orEmpty()) } }
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
@ -45,6 +48,7 @@ class TeacherPresenter @Inject constructor(
|
||||
hideRefresh()
|
||||
showProgress(false)
|
||||
enableSwipe(true)
|
||||
notifyParentDataLoaded()
|
||||
}
|
||||
}.subscribe({
|
||||
Timber.i("Loading teachers result: Success")
|
@ -1,9 +1,10 @@
|
||||
package io.github.wulkanowy.ui.modules.teacher
|
||||
package io.github.wulkanowy.ui.modules.schoolandteachers.teacher
|
||||
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||
import io.github.wulkanowy.ui.base.BaseView
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersChildView
|
||||
|
||||
interface TeacherView : BaseView {
|
||||
interface TeacherView : BaseView, SchoolAndTeachersChildView {
|
||||
|
||||
val isViewEmpty: Boolean
|
||||
|
@ -11,6 +11,7 @@ import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.ui.modules.message.MessageFragment
|
||||
import io.github.wulkanowy.ui.modules.more.MoreFragment
|
||||
import io.github.wulkanowy.ui.modules.note.NoteFragment
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragment
|
||||
import io.github.wulkanowy.ui.modules.settings.SettingsFragment
|
||||
import io.github.wulkanowy.ui.modules.timetable.TimetableFragment
|
||||
|
||||
@ -27,6 +28,7 @@ fun Fragment.toSection(): MainView.Section? {
|
||||
is LuckyNumberFragment -> MainView.Section.LUCKY_NUMBER
|
||||
is SettingsFragment -> MainView.Section.SETTINGS
|
||||
is AboutFragment -> MainView.Section.ABOUT
|
||||
is SchoolAndTeachersFragment -> MainView.Section.SCHOOL
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
9
app/src/main/res/drawable/ic_more_schoolandteachers.xml
Normal file
9
app/src/main/res/drawable/ic_more_schoolandteachers.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFF"
|
||||
android:pathData="M18,15H16V17H18M18,11H16V13H18M20,19H12V17H14V15H12V13H14V11H12V9H20M10,7H8V5H10M10,11H8V9H10M10,15H8V13H10M10,19H8V17H10M6,7H4V5H6M6,11H4V9H6M6,15H4V13H6M6,19H4V17H6M12,7V3H2V21H22V7H12Z" />
|
||||
</vector>
|
@ -1,7 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path android:fillColor="#fff" android:pathData="M16.36 12.76C18.31 13.42 20 14.5 20 16V21H4V16C4 14.5 5.69 13.42 7.65 12.76L8.27 14L8.5 14.5C7 14.96 5.9 15.62 5.9 16V19.1H10.12L11 14.03L10.06 12.15C10.68 12.08 11.33 12.03 12 12.03C12.67 12.03 13.32 12.08 13.94 12.15L13 14.03L13.88 19.1H18.1V16C18.1 15.62 17 14.96 15.5 14.5L15.73 14L16.36 12.76M12 5C10.9 5 10 5.9 10 7C10 8.1 10.9 9 12 9C13.1 9 14 8.1 14 7C14 5.9 13.1 5 12 5M12 11C9.79 11 8 9.21 8 7C8 4.79 9.79 3 12 3C14.21 3 16 4.79 16 7C16 9.21 14.21 11 12 11Z" />
|
||||
</vector>
|
195
app/src/main/res/layout/fragment_school.xml
Normal file
195
app/src/main/res/layout/fragment_school.xml
Normal file
@ -0,0 +1,195 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.modules.schoolandteachers.school.SchoolFragment">
|
||||
|
||||
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
|
||||
android:id="@+id/schoolProgress"
|
||||
style="@style/Widget.MaterialProgressBar.ProgressBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true" />
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/schoolSwipe"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/schoolContent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/school_name"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/schoolName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="17sp"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingTop="7dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingBottom="7dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/school_address"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/schoolAddress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="17sp"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingTop="7dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingBottom="7dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/school_telephone"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/schoolTelephone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="17sp"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingTop="7dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingBottom="7dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/school_headmaster"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/schoolHeadmaster"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="17sp"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingTop="7dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingBottom="7dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/school_pedagogue"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/schoolPedagogue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="17sp"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/schoolEmpty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp"
|
||||
android:visibility="gone"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
app:srcCompat="@drawable/ic_more_schoolandteachers"
|
||||
app:tint="?colorOnBackground"
|
||||
tools:ignore="contentDescription" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/teacher_no_items"
|
||||
android:textSize="20sp" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
38
app/src/main/res/layout/fragment_schoolandteachers.xml
Normal file
38
app/src/main/res/layout/fragment_schoolandteachers.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<io.github.wulkanowy.ui.widgets.MaterialTabLayout
|
||||
android:id="@+id/schoolandteachersTabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="?colorSurface"
|
||||
android:visibility="invisible"
|
||||
app:tabGravity="fill"
|
||||
app:tabIndicatorColor="?colorPrimary"
|
||||
app:tabMaxWidth="0dp"
|
||||
app:tabMode="fixed"
|
||||
app:tabSelectedTextColor="?colorPrimary"
|
||||
app:tabTextColor="@color/mtrl_on_surface_emphasis_medium"
|
||||
tools:ignore="UnusedAttribute"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/schoolandteachersViewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="48dp"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
|
||||
android:id="@+id/schoolandteachersProgress"
|
||||
style="@style/Widget.MaterialProgressBar.ProgressBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
@ -18,6 +18,7 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
tools:listitem="@layout/item_teacher"
|
||||
android:id="@+id/teacherRecycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
@ -36,7 +37,7 @@
|
||||
<ImageView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
app:srcCompat="@drawable/ic_more_teacher"
|
||||
app:srcCompat="@drawable/ic_more_schoolandteachers"
|
||||
app:tint="?colorOnBackground"
|
||||
tools:ignore="contentDescription" />
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -10,7 +9,7 @@
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingBottom="7dp"
|
||||
tools:context=".ui.modules.teacher.TeacherItem">
|
||||
tools:context=".ui.modules.schoolandteachers.teacher.TeacherItem">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/teacherItemName"
|
||||
|
@ -221,6 +221,19 @@
|
||||
<string name="mobile_device_pin">PIN</string>
|
||||
|
||||
|
||||
<!--School and teachers-->
|
||||
<string name="schoolandteachers_title">Szkoła i nauczyciele</string>
|
||||
|
||||
|
||||
<!--School-->
|
||||
<string name="school_title">Szkoła</string>
|
||||
<string name="school_name">Nazwa szkoły</string>
|
||||
<string name="school_address">Adres szkoły</string>
|
||||
<string name="school_telephone">Telefon</string>
|
||||
<string name="school_headmaster">Imię i nazwisko dyrektora</string>
|
||||
<string name="school_pedagogue">Imię i nazwisko pedagoga</string>
|
||||
|
||||
|
||||
<!--Teacher-->
|
||||
<string name="teachers_title">Nauczyciele</string>
|
||||
<string name="teacher_no_items">Brak informacji o nauczycielach</string>
|
||||
|
@ -207,6 +207,19 @@
|
||||
<string name="mobile_device_pin">PIN</string>
|
||||
|
||||
|
||||
<!--School and teachers-->
|
||||
<string name="schoolandteachers_title">School and teachers</string>
|
||||
|
||||
|
||||
<!--School-->
|
||||
<string name="school_title">School</string>
|
||||
<string name="school_name">School name</string>
|
||||
<string name="school_address">School address</string>
|
||||
<string name="school_telephone">Telephone</string>
|
||||
<string name="school_headmaster">Name of headmaster</string>
|
||||
<string name="school_pedagogue">Name of pedagogue</string>
|
||||
|
||||
|
||||
<!--Teacher-->
|
||||
<string name="teachers_title">Teachers</string>
|
||||
<string name="teacher_no_items">No info about teachers</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user