forked from github/wulkanowy-mirror
Show semester in appbar subtitle in grades view (#684)
This commit is contained in:
parent
1cc2080cb9
commit
34738a4839
@ -40,6 +40,8 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainVie
|
|||||||
|
|
||||||
override val titleStringId get() = R.string.grade_title
|
override val titleStringId get() = R.string.grade_title
|
||||||
|
|
||||||
|
override var subtitleString = ""
|
||||||
|
|
||||||
override val currentPageIndex get() = gradeViewPager.currentItem
|
override val currentPageIndex get() = gradeViewPager.currentItem
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -133,6 +135,11 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainVie
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setCurrentSemesterName(semester: Int, schoolYear: Int) {
|
||||||
|
subtitleString = getString(R.string.grade_subtitle, semester, schoolYear, schoolYear + 1)
|
||||||
|
(activity as MainView).setViewSubTitle(subtitleString)
|
||||||
|
}
|
||||||
|
|
||||||
fun onChildRefresh() {
|
fun onChildRefresh() {
|
||||||
presenter.onChildViewRefresh()
|
presenter.onChildViewRefresh()
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ class GradePresenter @Inject constructor(
|
|||||||
var selectedIndex = 0
|
var selectedIndex = 0
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
private var schoolYear = 0
|
||||||
|
|
||||||
private var semesters = emptyList<Semester>()
|
private var semesters = emptyList<Semester>()
|
||||||
|
|
||||||
private val loadedSemesterId = mutableMapOf<Int, Int>()
|
private val loadedSemesterId = mutableMapOf<Int, Int>()
|
||||||
@ -56,6 +58,7 @@ class GradePresenter @Inject constructor(
|
|||||||
selectedIndex = index + 1
|
selectedIndex = index + 1
|
||||||
loadedSemesterId.clear()
|
loadedSemesterId.clear()
|
||||||
view?.let {
|
view?.let {
|
||||||
|
it.setCurrentSemesterName(index + 1, schoolYear)
|
||||||
notifyChildrenSemesterChange()
|
notifyChildrenSemesterChange()
|
||||||
loadChild(it.currentPageIndex)
|
loadChild(it.currentPageIndex)
|
||||||
}
|
}
|
||||||
@ -96,16 +99,17 @@ class GradePresenter @Inject constructor(
|
|||||||
Timber.i("Loading grade data started")
|
Timber.i("Loading grade data started")
|
||||||
disposable.add(studentRepository.getCurrentStudent()
|
disposable.add(studentRepository.getCurrentStudent()
|
||||||
.flatMap { semesterRepository.getSemesters(it) }
|
.flatMap { semesterRepository.getSemesters(it) }
|
||||||
.doOnSuccess {
|
|
||||||
it.first { item -> item.isCurrent }.also { current ->
|
|
||||||
selectedIndex = if (selectedIndex == 0) current.semesterName else selectedIndex
|
|
||||||
semesters = it.filter { semester -> semester.diaryId == current.diaryId }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.subscribeOn(schedulers.backgroundThread)
|
.subscribeOn(schedulers.backgroundThread)
|
||||||
.observeOn(schedulers.mainThread)
|
.observeOn(schedulers.mainThread)
|
||||||
.doFinally { view?.showProgress(false) }
|
.doFinally { view?.showProgress(false) }
|
||||||
.subscribe({
|
.subscribe({
|
||||||
|
it.first { item -> item.isCurrent }.also { current ->
|
||||||
|
selectedIndex = if (selectedIndex == 0) current.semesterName else selectedIndex
|
||||||
|
schoolYear = current.schoolYear
|
||||||
|
semesters = it.filter { semester -> semester.diaryId == current.diaryId }
|
||||||
|
view?.setCurrentSemesterName(current.semesterName, schoolYear)
|
||||||
|
}
|
||||||
|
|
||||||
view?.run {
|
view?.run {
|
||||||
Timber.i("Loading grade result: Attempt load index $currentPageIndex")
|
Timber.i("Loading grade result: Attempt load index $currentPageIndex")
|
||||||
loadChild(currentPageIndex)
|
loadChild(currentPageIndex)
|
||||||
|
@ -20,6 +20,8 @@ interface GradeView : BaseView {
|
|||||||
|
|
||||||
fun showSemesterDialog(selectedIndex: Int)
|
fun showSemesterDialog(selectedIndex: Int)
|
||||||
|
|
||||||
|
fun setCurrentSemesterName(semester: Int, schoolYear: Int)
|
||||||
|
|
||||||
fun notifyChildLoadData(index: Int, semesterId: Int, forceRefresh: Boolean)
|
fun notifyChildLoadData(index: Int, semesterId: Int, forceRefresh: Boolean)
|
||||||
|
|
||||||
fun notifyChildParentReselected(index: Int)
|
fun notifyChildParentReselected(index: Int)
|
||||||
|
@ -12,7 +12,6 @@ import io.github.wulkanowy.R
|
|||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
import kotlinx.android.extensions.LayoutContainer
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
import kotlinx.android.synthetic.main.item_login_student_select.*
|
import kotlinx.android.synthetic.main.item_login_student_select.*
|
||||||
import timber.log.Timber
|
|
||||||
|
|
||||||
class LoginStudentSelectItem(val student: Student, val alreadySaved: Boolean) :
|
class LoginStudentSelectItem(val student: Student, val alreadySaved: Boolean) :
|
||||||
AbstractFlexibleItem<LoginStudentSelectItem.ItemViewHolder>() {
|
AbstractFlexibleItem<LoginStudentSelectItem.ItemViewHolder>() {
|
||||||
@ -20,8 +19,6 @@ class LoginStudentSelectItem(val student: Student, val alreadySaved: Boolean) :
|
|||||||
override fun getLayoutRes() = R.layout.item_login_student_select
|
override fun getLayoutRes() = R.layout.item_login_student_select
|
||||||
|
|
||||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<*>>): ItemViewHolder {
|
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<*>>): ItemViewHolder {
|
||||||
Timber.i("createViewHolder()")
|
|
||||||
Timber.i(alreadySaved.toString())
|
|
||||||
return ItemViewHolder(view, adapter)
|
return ItemViewHolder(view, adapter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +68,8 @@ class MainActivity : BaseActivity<MainPresenter>(), MainView {
|
|||||||
|
|
||||||
override val currentViewTitle get() = (navController.currentFrag as? MainView.TitledView)?.titleStringId?.let { getString(it) }
|
override val currentViewTitle get() = (navController.currentFrag as? MainView.TitledView)?.titleStringId?.let { getString(it) }
|
||||||
|
|
||||||
|
override val currentViewSubtitle get() = (navController.currentFrag as? MainView.TitledView)?.subtitleString
|
||||||
|
|
||||||
override var startMenuIndex = 0
|
override var startMenuIndex = 0
|
||||||
|
|
||||||
override var startMenuMoreIndex = -1
|
override var startMenuMoreIndex = -1
|
||||||
@ -152,6 +154,10 @@ class MainActivity : BaseActivity<MainPresenter>(), MainView {
|
|||||||
supportActionBar?.title = title
|
supportActionBar?.title = title
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setViewSubTitle(subtitle: String?) {
|
||||||
|
supportActionBar?.subtitle = subtitle
|
||||||
|
}
|
||||||
|
|
||||||
override fun showHomeArrow(show: Boolean) {
|
override fun showHomeArrow(show: Boolean) {
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(show)
|
supportActionBar?.setDisplayHomeAsUpEnabled(show)
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ class MainPresenter @Inject constructor(
|
|||||||
view?.apply {
|
view?.apply {
|
||||||
showActionBarElevation(section != GRADE && section != MESSAGE && section != SCHOOL)
|
showActionBarElevation(section != GRADE && section != MESSAGE && section != SCHOOL)
|
||||||
currentViewTitle?.let { setViewTitle(it) }
|
currentViewTitle?.let { setViewTitle(it) }
|
||||||
|
currentViewSubtitle?.let { setViewSubTitle(it.ifBlank { null }) }
|
||||||
currentStackSize?.let {
|
currentStackSize?.let {
|
||||||
if (it > 1) showHomeArrow(true)
|
if (it > 1) showHomeArrow(true)
|
||||||
else showHomeArrow(false)
|
else showHomeArrow(false)
|
||||||
|
@ -12,6 +12,8 @@ interface MainView : BaseView {
|
|||||||
|
|
||||||
val currentViewTitle: String?
|
val currentViewTitle: String?
|
||||||
|
|
||||||
|
val currentViewSubtitle: String?
|
||||||
|
|
||||||
val currentStackSize: Int?
|
val currentStackSize: Int?
|
||||||
|
|
||||||
fun initView()
|
fun initView()
|
||||||
@ -30,6 +32,8 @@ interface MainView : BaseView {
|
|||||||
|
|
||||||
fun setViewTitle(title: String)
|
fun setViewTitle(title: String)
|
||||||
|
|
||||||
|
fun setViewSubTitle(subtitle: String?)
|
||||||
|
|
||||||
fun popView(depth: Int = 1)
|
fun popView(depth: Int = 1)
|
||||||
|
|
||||||
interface MainChildView {
|
interface MainChildView {
|
||||||
@ -42,6 +46,10 @@ interface MainView : BaseView {
|
|||||||
interface TitledView {
|
interface TitledView {
|
||||||
|
|
||||||
val titleStringId: Int
|
val titleStringId: Int
|
||||||
|
|
||||||
|
var subtitleString: String
|
||||||
|
get() = ""
|
||||||
|
set(_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class Section(val id: Int) {
|
enum class Section(val id: Int) {
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
<string name="homework_title">Zadania domowe</string>
|
<string name="homework_title">Zadania domowe</string>
|
||||||
<string name="account_title">Wybierz konto</string>
|
<string name="account_title">Wybierz konto</string>
|
||||||
|
|
||||||
|
<!--Subtitles-->
|
||||||
|
<string name="grade_subtitle">Semestr %d, %d/%d</string>
|
||||||
|
|
||||||
|
|
||||||
<!--Login-->
|
<!--Login-->
|
||||||
<string name="login_header_default">Zaloguj się za pomocą konta ucznia lub rodzica</string>
|
<string name="login_header_default">Zaloguj się za pomocą konta ucznia lub rodzica</string>
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
<string name="homework_title">Домашние задания</string>
|
<string name="homework_title">Домашние задания</string>
|
||||||
<string name="account_title">Выберите аккаунт</string>
|
<string name="account_title">Выберите аккаунт</string>
|
||||||
|
|
||||||
|
<!--Subtitles-->
|
||||||
|
<string name="grade_subtitle">Семестр %d, %d/%d</string>
|
||||||
|
|
||||||
|
|
||||||
<!--Login-->
|
<!--Login-->
|
||||||
<string name="login_header_default">Авторизируйтесь при помощи аккаунта ученика или родителя</string>
|
<string name="login_header_default">Авторизируйтесь при помощи аккаунта ученика или родителя</string>
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
<string name="homework_title">Homework</string>
|
<string name="homework_title">Homework</string>
|
||||||
<string name="account_title">Choose account</string>
|
<string name="account_title">Choose account</string>
|
||||||
|
|
||||||
|
<!--Subtitles-->
|
||||||
|
<string name="grade_subtitle">Semester %d, %d/%d</string>
|
||||||
|
|
||||||
|
|
||||||
<!--Login-->
|
<!--Login-->
|
||||||
<string name="login_header_default">Sign in with the student or parent account</string>
|
<string name="login_header_default">Sign in with the student or parent account</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user