From 4e3b2a7ec0b9ce7fc526dbdf0667caad7ba4dd49 Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 17 Jul 2024 12:12:03 +0800 Subject: [PATCH] Migrate outdated APIs --- .../calendar/sample/compose/Example8Page.kt | 2 -- .../kizitonwose/calendar/sample/compose/ListPage.kt | 2 +- .../com/kizitonwose/calendar/sample/compose/Utils.kt | 2 +- .../calendar/sample/view/CalendarViewActivity.kt | 2 +- .../com/kizitonwose/calendar/view/internal/Utils.kt | 10 ++-------- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example8Page.kt b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example8Page.kt index a07d2c87..1543e869 100644 --- a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example8Page.kt +++ b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example8Page.kt @@ -19,7 +19,6 @@ import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color @@ -189,7 +188,6 @@ private fun MonthHeader(daysOfWeek: List) { } } -@OptIn(ExperimentalComposeUiApi::class) @Composable private fun MonthFooter(selectionCount: Int) { Box( diff --git a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/ListPage.kt b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/ListPage.kt index ac442b33..36615fa5 100644 --- a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/ListPage.kt +++ b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/ListPage.kt @@ -80,7 +80,7 @@ fun ListPage(click: (Page) -> Unit) { .fillMaxSize() .background(Color.White), ) { - items(Page.values().drop(1)) { item -> + items(Page.entries.drop(1)) { item -> Column( modifier = Modifier .fillParentMaxWidth() diff --git a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Utils.kt b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Utils.kt index 97528f45..b5e699e5 100644 --- a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Utils.kt +++ b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Utils.kt @@ -24,9 +24,9 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalInspectionMode -import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.semantics.Role import androidx.compose.ui.unit.dp +import androidx.lifecycle.compose.LocalLifecycleOwner import com.kizitonwose.calendar.compose.CalendarLayoutInfo import com.kizitonwose.calendar.compose.CalendarState import com.kizitonwose.calendar.compose.weekcalendar.WeekCalendarState diff --git a/sample/src/main/java/com/kizitonwose/calendar/sample/view/CalendarViewActivity.kt b/sample/src/main/java/com/kizitonwose/calendar/sample/view/CalendarViewActivity.kt index 6c9cc9f1..184caafb 100644 --- a/sample/src/main/java/com/kizitonwose/calendar/sample/view/CalendarViewActivity.kt +++ b/sample/src/main/java/com/kizitonwose/calendar/sample/view/CalendarViewActivity.kt @@ -37,7 +37,7 @@ class CalendarViewActivity : AppCompatActivity() { override fun onOptionsItemSelected(item: MenuItem): Boolean { return when (item.itemId) { - android.R.id.home -> onBackPressed().let { true } + android.R.id.home -> onBackPressedDispatcher.onBackPressed().let { true } else -> super.onOptionsItemSelected(item) } } diff --git a/view/src/main/java/com/kizitonwose/calendar/view/internal/Utils.kt b/view/src/main/java/com/kizitonwose/calendar/view/internal/Utils.kt index 4d0cd1c9..f52981a6 100644 --- a/view/src/main/java/com/kizitonwose/calendar/view/internal/Utils.kt +++ b/view/src/main/java/com/kizitonwose/calendar/view/internal/Utils.kt @@ -1,7 +1,6 @@ package com.kizitonwose.calendar.view.internal import android.content.Context -import android.os.Build import android.util.Log import android.view.View import android.view.ViewGroup @@ -75,13 +74,8 @@ internal fun setupItemRoot( root.layoutParams = MarginLayoutParams(width, height).apply { bottomMargin = itemMargins.bottom topMargin = itemMargins.top - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - marginStart = itemMargins.start - marginEnd = itemMargins.end - } else { - leftMargin = itemMargins.start - rightMargin = itemMargins.end - } + marginStart = itemMargins.start + marginEnd = itemMargins.end } }