Fix grade fragment subtitle (#1185)

This commit is contained in:
Rafał Borcz 2021-03-06 13:01:41 +01:00 committed by GitHub
parent 6f590eb194
commit 3b970209a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 12 deletions

View File

@ -34,8 +34,6 @@ class AccountFragment : BaseFragment<FragmentAccountBinding>(R.layout.fragment_a
override val titleStringId = R.string.account_title override val titleStringId = R.string.account_title
override var subtitleString = ""
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setHasOptionsMenu(true) setHasOptionsMenu(true)

View File

@ -33,8 +33,6 @@ class AccountDetailsFragment :
override val titleStringId = R.string.account_details_title override val titleStringId = R.string.account_details_title
override var subtitleString = ""
companion object { companion object {
private const val ARGUMENT_KEY = "Data" private const val ARGUMENT_KEY = "Data"

View File

@ -63,11 +63,13 @@ class GradeFragment : BaseFragment<FragmentGradeBinding>(R.layout.fragment_grade
override fun initView() { override fun initView() {
with(pagerAdapter) { with(pagerAdapter) {
containerId = binding.gradeViewPager.id containerId = binding.gradeViewPager.id
addFragmentsWithTitle(mapOf( addFragmentsWithTitle(
mapOf(
GradeDetailsFragment.newInstance() to getString(R.string.all_details), GradeDetailsFragment.newInstance() to getString(R.string.all_details),
GradeSummaryFragment.newInstance() to getString(R.string.grade_menu_summary), GradeSummaryFragment.newInstance() to getString(R.string.grade_menu_summary),
GradeStatisticsFragment.newInstance() to getString(R.string.grade_menu_statistics) GradeStatisticsFragment.newInstance() to getString(R.string.grade_menu_statistics)
)) )
)
} }
with(binding.gradeViewPager) { with(binding.gradeViewPager) {
@ -137,7 +139,10 @@ class GradeFragment : BaseFragment<FragmentGradeBinding>(R.layout.fragment_grade
override fun setCurrentSemesterName(semester: Int, schoolYear: Int) { override fun setCurrentSemesterName(semester: Int, schoolYear: Int) {
subtitleString = getString(R.string.grade_subtitle, semester, schoolYear, schoolYear + 1) subtitleString = getString(R.string.grade_subtitle, semester, schoolYear, schoolYear + 1)
(activity as MainView).setViewSubTitle(subtitleString)
if (isVisible) {
(activity as MainView?)?.setViewSubTitle(subtitleString)
}
} }
fun onChildRefresh() { fun onChildRefresh() {
@ -149,7 +154,8 @@ class GradeFragment : BaseFragment<FragmentGradeBinding>(R.layout.fragment_grade
} }
override fun notifyChildLoadData(index: Int, semesterId: Int, forceRefresh: Boolean) { override fun notifyChildLoadData(index: Int, semesterId: Int, forceRefresh: Boolean) {
(pagerAdapter.getFragmentInstance(index) as? GradeView.GradeChildView)?.onParentLoadData(semesterId, forceRefresh) (pagerAdapter.getFragmentInstance(index) as? GradeView.GradeChildView)
?.onParentLoadData(semesterId, forceRefresh)
} }
override fun notifyChildParentReselected(index: Int) { override fun notifyChildParentReselected(index: Int) {