diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/v2/TimetablePagerAdapter.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/v2/TimetablePagerAdapter.kt index 63ecdd6d..45a5e5d1 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/v2/TimetablePagerAdapter.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/v2/TimetablePagerAdapter.kt @@ -1,8 +1,10 @@ package pl.szczodrzynski.edziennik.ui.modules.timetable.v2 +import android.os.Bundle import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentStatePagerAdapter +import pl.szczodrzynski.edziennik.ui.modules.timetable.v2.day.TimetableDayFragment import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Week @@ -16,7 +18,11 @@ class TimetablePagerAdapter(val fragmentManager: FragmentManager, val items: Lis private val weekEnd by lazy { weekStart.clone().stepForward(0, 0, 6) } override fun getItem(position: Int): Fragment { - return pl.szczodrzynski.edziennik.ui.modules.timetable.v2.day.TimetableDayFragment(items[position]) + return TimetableDayFragment().apply { + arguments = Bundle().apply { + putInt("date", items[position].value) + } + } /*return TimetableDayFragment().apply { arguments = Bundle().also { it.putLong("date", items[position].value.toLong()) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/v2/day/TimetableDayFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/v2/day/TimetableDayFragment.kt index 3afcc2ba..953cd7d7 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/v2/day/TimetableDayFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/v2/day/TimetableDayFragment.kt @@ -25,7 +25,7 @@ import pl.szczodrzynski.navlib.getColorFromAttr import java.util.* import kotlin.math.min -class TimetableDayFragment(val date: Date) : Fragment() { +class TimetableDayFragment() : Fragment() { companion object { private const val TAG = "TimetableDayFragment" } @@ -33,6 +33,7 @@ class TimetableDayFragment(val date: Date) : Fragment() { private lateinit var app: App private lateinit var activity: MainActivity private lateinit var b: FragmentTimetableV2DayBinding + private lateinit var date: Date override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { activity = (getActivity() as MainActivity?) ?: return null @@ -40,7 +41,7 @@ class TimetableDayFragment(val date: Date) : Fragment() { return null app = activity.application as App b = FragmentTimetableV2DayBinding.inflate(inflater) - Log.d(TAG, "onCreateView, date=$date") + date = arguments?.getInt("date")?.let { Date.fromValue(it) } ?: Date.getToday() return b.root }