mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Fix a bunch of random lint warnings.
This commit is contained in:
committed by
Nicholas Tinsley
parent
ce4b7c2d7f
commit
6922886395
@@ -0,0 +1,23 @@
|
||||
package org.signal.core.util
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
|
||||
fun <T : Parcelable> Bundle.getParcelableCompat(key: String, clazz: Class<T>): T? {
|
||||
return if (Build.VERSION.SDK_INT >= 33) {
|
||||
this.getParcelable(key, clazz)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
this.getParcelable(key)
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Parcelable> Bundle.getParcelableArrayListCompat(key: String, clazz: Class<T>): ArrayList<T>? {
|
||||
return if (Build.VERSION.SDK_INT >= 33) {
|
||||
this.getParcelableArrayList(key, clazz)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
this.getParcelableArrayList(key)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.signal.core.util
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Parcelable
|
||||
|
||||
fun <T : Parcelable> Intent.getParcelableExtraCompat(key: String, clazz: Class<T>): T? {
|
||||
return if (Build.VERSION.SDK_INT >= 33) {
|
||||
this.getParcelableExtra(key, clazz)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
this.getParcelableExtra(key)
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Parcelable> Intent.getParcelableArrayListExtraCompat(key: String, clazz: Class<T>): ArrayList<T>? {
|
||||
return if (Build.VERSION.SDK_INT >= 33) {
|
||||
this.getParcelableArrayListExtra(key, clazz)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
this.getParcelableArrayListExtra(key)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.signal.core.util
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
fun <T : Parcelable> Parcel.readParcelableCompat(clazz: Class<T>): T? {
|
||||
return if (Build.VERSION.SDK_INT >= 33) {
|
||||
this.readParcelable(clazz.classLoader, clazz)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
this.readParcelable(clazz.classLoader)
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : java.io.Serializable> Parcel.readSerializableCompat(clazz: Class<T>): T? {
|
||||
return if (Build.VERSION.SDK_INT >= 33) {
|
||||
this.readSerializable(clazz.classLoader, clazz)
|
||||
} else {
|
||||
@Suppress("DEPRECATION", "UNCHECKED_CAST")
|
||||
this.readSerializable() as T
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user