diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/Destination.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/Destination.kt index f49c4889..f8c456fe 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/Destination.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/Destination.kt @@ -1,5 +1,6 @@ package io.github.wulkanowy.ui.modules +import android.os.Parcelable import androidx.fragment.app.Fragment import io.github.wulkanowy.data.serializers.LocalDateSerializer import io.github.wulkanowy.ui.modules.attendance.AttendanceFragment @@ -15,11 +16,12 @@ import io.github.wulkanowy.ui.modules.note.NoteFragment import io.github.wulkanowy.ui.modules.schoolandteachers.school.SchoolFragment import io.github.wulkanowy.ui.modules.schoolannouncement.SchoolAnnouncementFragment import io.github.wulkanowy.ui.modules.timetable.TimetableFragment +import kotlinx.parcelize.Parcelize import kotlinx.serialization.Serializable import java.time.LocalDate @Serializable -sealed class Destination private constructor() : java.io.Serializable { +sealed class Destination private constructor() : Parcelable { /* Type in children classes have to be as getter to avoid null in enums @@ -45,30 +47,35 @@ sealed class Destination private constructor() : java.io.Serializable { MESSAGE(Message); } + @Parcelize @Serializable object Dashboard : Destination() { override val type get() = Type.DASHBOARD override val fragment get() = DashboardFragment.newInstance() } + @Parcelize @Serializable object Grade : Destination() { override val type get() = Type.GRADE override val fragment get() = GradeFragment.newInstance() } + @Parcelize @Serializable object Attendance : Destination() { override val type get() = Type.ATTENDANCE override val fragment get() = AttendanceFragment.newInstance() } + @Parcelize @Serializable object Exam : Destination() { override val type get() = Type.EXAM override val fragment get() = ExamFragment.newInstance() } + @Parcelize @Serializable data class Timetable( @Serializable(with = LocalDateSerializer::class) @@ -78,51 +85,59 @@ sealed class Destination private constructor() : java.io.Serializable { override val fragment get() = TimetableFragment.newInstance(date) } + @Parcelize @Serializable object Homework : Destination() { override val type get() = Type.HOMEWORK override val fragment get() = HomeworkFragment.newInstance() } + @Parcelize @Serializable object Note : Destination() { override val type get() = Type.NOTE override val fragment get() = NoteFragment.newInstance() } + @Parcelize @Serializable object Conference : Destination() { override val type get() = Type.CONFERENCE override val fragment get() = ConferenceFragment.newInstance() } + @Parcelize @Serializable object SchoolAnnouncement : Destination() { override val type get() = Type.SCHOOL_ANNOUNCEMENT override val fragment get() = SchoolAnnouncementFragment.newInstance() } + @Parcelize @Serializable object School : Destination() { override val type get() = Type.SCHOOL override val fragment get() = SchoolFragment.newInstance() } + @Parcelize @Serializable object LuckyNumber : Destination() { override val type get() = Type.LUCKY_NUMBER override val fragment get() = LuckyNumberFragment.newInstance() } + @Parcelize @Serializable object More : Destination() { override val type get() = Type.MORE override val fragment get() = MoreFragment.newInstance() } + @Parcelize @Serializable object Message : Destination() { override val type get() = Type.MESSAGE override val fragment get() = MessageFragment.newInstance() } -} \ No newline at end of file +} diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt index 0cd38ac7..d1f32447 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt @@ -86,7 +86,7 @@ class MainActivity : BaseActivity(), MainVie messageContainer = binding.mainMessageContainer updateHelper.messageContainer = binding.mainFragmentContainer - val destination = (intent.getSerializableExtra(EXTRA_START_DESTINATION) as Destination?) + val destination = (intent.getParcelableExtra(EXTRA_START_DESTINATION) as Destination?) ?.takeIf { savedInstanceState == null } presenter.onAttachView(this, destination) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt index a86024e4..24347e73 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt @@ -45,7 +45,7 @@ class SplashActivity : BaseActivity(), SplashView installSplashScreen().setKeepOnScreenCondition { true } val externalLink = intent?.getStringExtra(EXTRA_EXTERNAL_URL) - val startDestination = intent?.getSerializableExtra(EXTRA_START_DESTINATION) as Destination? + val startDestination = intent?.getParcelableExtra(EXTRA_START_DESTINATION) as Destination? ?: shortcutsHelper.getDestination(intent) presenter.onAttachView(this, externalLink, startDestination)