Skip to content

Commit

Permalink
Use IntentCompat.getSerializableExtra
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaniskandar committed May 22, 2024
1 parent 377679c commit 82795b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.core.content.IntentCompat
import xyz.ivaniskandar.shouko.R
import xyz.ivaniskandar.shouko.service.TadanoTileParentService
import xyz.ivaniskandar.shouko.service.TadanoTileParentService.Companion.EXTRA_SERVICE_TYPE
Expand All @@ -34,7 +35,8 @@ import xyz.ivaniskandar.shouko.ui.theme.ShoukoM3Theme
class TileBoardingActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val type = intent.getSerializableExtra(EXTRA_SERVICE_TYPE) as? TadanoTileParentService.Type
val type = IntentCompat
.getSerializableExtra(intent, EXTRA_SERVICE_TYPE, TadanoTileParentService.Type::class.java)
if (type == null) {
finish()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import android.provider.Settings
import android.service.quicksettings.TileService
import androidx.core.app.NotificationCompat
import androidx.core.app.ServiceCompat
import androidx.core.content.IntentCompat
import androidx.core.content.getSystemService
import com.kieronquinn.monetcompat.core.MonetCompat
import xyz.ivaniskandar.shouko.R
Expand Down Expand Up @@ -116,7 +117,7 @@ class TadanoTileParentService : Service() {
channelSettingsIntent,
PendingIntent.FLAG_IMMUTABLE,
)
val type = intent.getSerializableExtra(EXTRA_SERVICE_TYPE) as Type
val type = IntentCompat.getSerializableExtra(intent, EXTRA_SERVICE_TYPE, Type::class.java)!!
val icon = when (type) {
Type.COFFEE -> R.drawable.ic_coffee
Type.TEA -> R.drawable.ic_tea
Expand Down Expand Up @@ -219,7 +220,7 @@ class TadanoTileParentService : Service() {
stopSelf()
}

@SuppressLint("WakelockTimeout")
@SuppressLint("WakelockTimeout", "Wakelock")
private fun switchTeaWakeLock(acquire: Boolean) {
if (acquire) {
if (!teaWakeLock.isHeld) {
Expand All @@ -232,7 +233,7 @@ class TadanoTileParentService : Service() {
}
}

@SuppressLint("WakelockTimeout")
@SuppressLint("WakelockTimeout", "Wakelock")
private fun switchCoffeeWakeLock(acquire: Boolean) {
if (acquire) {
if (!coffeeWakeLock.isHeld) {
Expand Down

0 comments on commit 82795b9

Please sign in to comment.