forked from github/wulkanowy-mirror
Add missing dashboard item in default view settings (#1450)
This commit is contained in:
parent
cebd1aa75d
commit
55518cb044
@ -30,6 +30,7 @@ class PreferencesRepository @Inject constructor(
|
||||
@ApplicationContext val context: Context,
|
||||
moshi: Moshi
|
||||
) {
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
private val dashboardItemsPositionAdapter: JsonAdapter<Map<DashboardItem.Type, Int>> =
|
||||
moshi.adapter()
|
||||
|
@ -20,7 +20,7 @@ import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class ExamFragment : BaseFragment<FragmentExamBinding>(R.layout.fragment_exam), ExamView,
|
||||
MainView.MainChildView, MainView.TitledView {
|
||||
MainView.TitledView {
|
||||
|
||||
@Inject
|
||||
lateinit var presenter: ExamPresenter
|
||||
@ -90,14 +90,6 @@ class ExamFragment : BaseFragment<FragmentExamBinding>(R.layout.fragment_exam),
|
||||
}
|
||||
}
|
||||
|
||||
override fun resetView() {
|
||||
binding.examRecycler.scrollToPosition(0)
|
||||
}
|
||||
|
||||
override fun onFragmentReselected() {
|
||||
if (::presenter.isInitialized) presenter.onViewReselected()
|
||||
}
|
||||
|
||||
override fun showEmpty(show: Boolean) {
|
||||
binding.examEmpty.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
@ -82,16 +82,6 @@ class ExamPresenter @Inject constructor(
|
||||
view?.showExamDialog(exam)
|
||||
}
|
||||
|
||||
fun onViewReselected() {
|
||||
Timber.i("Exam view is reselected")
|
||||
baseDate.also {
|
||||
if (currentDate != it) {
|
||||
reloadView(it)
|
||||
loadData()
|
||||
} else if (view?.isViewEmpty == false) view?.resetView()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setBaseDateOnHolidays() {
|
||||
flow {
|
||||
val student = studentRepository.getCurrentStudent()
|
||||
|
@ -17,8 +17,6 @@ interface ExamView : BaseView {
|
||||
|
||||
fun showRefresh(show: Boolean)
|
||||
|
||||
fun resetView()
|
||||
|
||||
fun showEmpty(show: Boolean)
|
||||
|
||||
fun showErrorView(show: Boolean)
|
||||
|
@ -34,6 +34,7 @@ import io.github.wulkanowy.ui.modules.account.accountquick.AccountQuickDialog
|
||||
import io.github.wulkanowy.ui.modules.attendance.AttendanceFragment
|
||||
import io.github.wulkanowy.ui.modules.conference.ConferenceFragment
|
||||
import io.github.wulkanowy.ui.modules.dashboard.DashboardFragment
|
||||
import io.github.wulkanowy.ui.modules.exam.ExamFragment
|
||||
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
||||
import io.github.wulkanowy.ui.modules.homework.HomeworkFragment
|
||||
import io.github.wulkanowy.ui.modules.luckynumber.LuckyNumberFragment
|
||||
@ -107,11 +108,12 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
||||
|
||||
private val moreMenuFragments = mapOf<Int, Fragment>(
|
||||
MainView.Section.MESSAGE.id to MessageFragment.newInstance(),
|
||||
MainView.Section.EXAM.id to ExamFragment.newInstance(),
|
||||
MainView.Section.HOMEWORK.id to HomeworkFragment.newInstance(),
|
||||
MainView.Section.NOTE.id to NoteFragment.newInstance(),
|
||||
MainView.Section.LUCKY_NUMBER.id to LuckyNumberFragment.newInstance(),
|
||||
MainView.Section.SCHOOL_ANNOUNCEMENT.id to SchoolAnnouncementFragment.newInstance(),
|
||||
MainView.Section.CONFERENCE.id to ConferenceFragment.newInstance(),
|
||||
MainView.Section.SCHOOL_ANNOUNCEMENT.id to SchoolAnnouncementFragment.newInstance(),
|
||||
MainView.Section.LUCKY_NUMBER.id to LuckyNumberFragment.newInstance(),
|
||||
)
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
|
@ -118,11 +118,9 @@ class MainPresenter @Inject constructor(
|
||||
view?.showStudentAvatar(currentStudent)
|
||||
}
|
||||
|
||||
private fun getProperViewIndexes(initMenu: MainView.Section?): Pair<Int, Int> {
|
||||
return when (initMenu?.id) {
|
||||
in 0..3 -> initMenu!!.id to -1
|
||||
in 4..10 -> 4 to initMenu!!.id
|
||||
else -> prefRepository.startMenuIndex to -1
|
||||
}
|
||||
private fun getProperViewIndexes(initMenu: MainView.Section?) = when (initMenu?.id) {
|
||||
in 0..3 -> initMenu!!.id to -1
|
||||
in 4..100 -> 4 to initMenu!!.id
|
||||
else -> prefRepository.startMenuIndex to -1
|
||||
}
|
||||
}
|
||||
|
@ -56,22 +56,24 @@ interface MainView : BaseView {
|
||||
set(_) {}
|
||||
}
|
||||
|
||||
enum class Section(val id: Int) {
|
||||
GRADE(0),
|
||||
ATTENDANCE(1),
|
||||
EXAM(2),
|
||||
TIMETABLE(3),
|
||||
MORE(4),
|
||||
MESSAGE(5),
|
||||
HOMEWORK(6),
|
||||
NOTE(7),
|
||||
LUCKY_NUMBER(8),
|
||||
SETTINGS(9),
|
||||
ABOUT(10),
|
||||
SCHOOL(11),
|
||||
ACCOUNT(12),
|
||||
STUDENT_INFO(13),
|
||||
CONFERENCE(14),
|
||||
SCHOOL_ANNOUNCEMENT(15)
|
||||
enum class Section {
|
||||
DASHBOARD,
|
||||
GRADE,
|
||||
ATTENDANCE,
|
||||
TIMETABLE,
|
||||
MORE,
|
||||
MESSAGE,
|
||||
EXAM,
|
||||
HOMEWORK,
|
||||
NOTE,
|
||||
CONFERENCE,
|
||||
SCHOOL_ANNOUNCEMENT,
|
||||
SCHOOL,
|
||||
LUCKY_NUMBER,
|
||||
ACCOUNT,
|
||||
STUDENT_INFO,
|
||||
SETTINGS;
|
||||
|
||||
val id get() = ordinal
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package io.github.wulkanowy.utils
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import io.github.wulkanowy.ui.modules.about.AboutFragment
|
||||
import io.github.wulkanowy.ui.modules.account.AccountFragment
|
||||
import io.github.wulkanowy.ui.modules.account.accountdetails.AccountDetailsFragment
|
||||
import io.github.wulkanowy.ui.modules.attendance.AttendanceFragment
|
||||
import io.github.wulkanowy.ui.modules.conference.ConferenceFragment
|
||||
import io.github.wulkanowy.ui.modules.dashboard.DashboardFragment
|
||||
import io.github.wulkanowy.ui.modules.exam.ExamFragment
|
||||
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
||||
import io.github.wulkanowy.ui.modules.homework.HomeworkFragment
|
||||
@ -32,13 +32,13 @@ fun Fragment.toSection(): MainView.Section? {
|
||||
is NoteFragment -> MainView.Section.NOTE
|
||||
is LuckyNumberFragment -> MainView.Section.LUCKY_NUMBER
|
||||
is SettingsFragment -> MainView.Section.SETTINGS
|
||||
is AboutFragment -> MainView.Section.ABOUT
|
||||
is SchoolAndTeachersFragment -> MainView.Section.SCHOOL
|
||||
is AccountFragment -> MainView.Section.ACCOUNT
|
||||
is AccountDetailsFragment -> MainView.Section.ACCOUNT
|
||||
is StudentInfoFragment -> MainView.Section.STUDENT_INFO
|
||||
is ConferenceFragment -> MainView.Section.CONFERENCE
|
||||
is SchoolAnnouncementFragment -> MainView.Section.SCHOOL_ANNOUNCEMENT
|
||||
is DashboardFragment -> MainView.Section.DASHBOARD
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||
<string name="pref_key_start_menu">start_menu</string>
|
||||
<string name="pref_key_start_menu">default_menu_index</string>
|
||||
<string name="pref_key_attendance_present">attendance_present</string>
|
||||
<string name="pref_key_app_theme">app_theme</string>
|
||||
<string name="pref_key_dashboard_tiles">dashboard_tiles</string>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<string-array name="startup_tab_entries" translatable="false">
|
||||
<item>@string/dashboard_title</item>
|
||||
<item>@string/grade_title</item>
|
||||
<item>@string/attendance_title</item>
|
||||
<item>@string/exam_title</item>
|
||||
<item>@string/timetable_title</item>
|
||||
</string-array>
|
||||
<string-array name="startup_tab_value" translatable="false">
|
||||
|
Loading…
x
Reference in New Issue
Block a user