Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions app/src/main/java/com/example/cahier/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package com.example.cahier

import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
Expand All @@ -27,6 +26,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import androidx.core.content.IntentCompat
import com.example.cahier.data.NoteType
import com.example.cahier.ui.CahierApp
import com.example.cahier.ui.theme.CahierAppTheme
Expand All @@ -39,15 +39,11 @@ class MainActivity : ComponentActivity() {
enableEdgeToEdge()

val noteId = intent.getLongExtra(AppArgs.NOTE_ID_KEY, -1)
val noteType = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableExtra(AppArgs.NOTE_TYPE_KEY, NoteType::class.java)
}
else {
// The old way to get the parcelable extra is deprecated as of API 33, but we use it
// because we need to support older versions of Android.
@Suppress("DEPRECATION")
intent.getParcelableExtra(AppArgs.NOTE_TYPE_KEY) as NoteType?
}
val noteType = IntentCompat.getParcelableExtra(
intent,
AppArgs.NOTE_TYPE_KEY,
NoteType::class.java
)

setContent {
CahierAppTheme {
Expand Down
Loading