Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deprecated Parcel functions #18068

Merged
Prev Previous commit
Next Next commit
Use ParcelCompat for Android 13 changes
  • Loading branch information
irfano committed Mar 8, 2023
commit d33a1999fc17e2ea833b0a4e6e6b65f7e69fbb20
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.net.Uri
import android.os.Parcel
import android.os.Parcelable
import android.os.Parcelable.Creator
import androidx.core.os.ParcelCompat
import org.wordpress.android.ui.mediapicker.MediaItem.IdentifierType.GIF_MEDIA_IDENTIFIER
import org.wordpress.android.ui.mediapicker.MediaItem.IdentifierType.LOCAL_ID
import org.wordpress.android.ui.mediapicker.MediaItem.IdentifierType.LOCAL_URI
Expand Down Expand Up @@ -82,7 +83,15 @@ data class MediaItem(
return when (type) {
LOCAL_URI -> {
LocalUri(
UriWrapper(requireNotNull(parcel.readParcelable(Uri::class.java.classLoader))),
UriWrapper(
requireNotNull(
ParcelCompat.readParcelable(
parcel,
Uri::class.java.classLoader,
Uri::class.java
)
)
),
parcel.readInt() != 0
)
}
Expand All @@ -97,7 +106,15 @@ data class MediaItem(
}
GIF_MEDIA_IDENTIFIER -> {
GifMediaIdentifier(
UriWrapper(requireNotNull(parcel.readParcelable(Uri::class.java.classLoader))),
UriWrapper(
requireNotNull(
ParcelCompat.readParcelable(
parcel,
Uri::class.java.classLoader,
Uri::class.java
)
)
),
parcel.readString()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.os.Bundle
import android.os.Parcel
import android.os.Parcelable
import androidx.core.os.ParcelCompat
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import kotlinx.parcelize.Parceler
Expand Down Expand Up @@ -223,7 +224,7 @@ class SelectedDateProvider
null
}
val availableTimeStamps = mutableListOf<Any?>()
parcel.readList(availableTimeStamps, null)
ParcelCompat.readList(parcel, availableTimeStamps, null, Any::class.java)
val availableDates = availableTimeStamps.map { Date(it as Long) }
val loading = parcel.readValue(null) as Boolean
val error = parcel.readValue(null) as Boolean
Expand Down