Fix a bunch of random lint warnings.

This commit is contained in:
Greyson Parrelli
2023-02-26 13:45:24 -05:00
committed by Nicholas Tinsley
parent ce4b7c2d7f
commit 6922886395
75 changed files with 293 additions and 213 deletions

View File

@@ -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)
}
}

View File

@@ -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)
}
}

View File

@@ -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
}
}