Initial commit
This commit is contained in:
commit
21bfbfb139
520 changed files with 47819 additions and 0 deletions
22
app/src/main/java/ani/dantotsu/others/Idiosyncrasy.kt
Normal file
22
app/src/main/java/ani/dantotsu/others/Idiosyncrasy.kt
Normal file
|
@ -0,0 +1,22 @@
|
|||
@file:Suppress("UNCHECKED_CAST", "DEPRECATION")
|
||||
|
||||
package ani.dantotsu.others
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import java.io.Serializable
|
||||
|
||||
inline fun <reified T : Serializable> Bundle.getSerialized(key: String): T? {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
|
||||
this.getSerializable(key, T::class.java)
|
||||
else
|
||||
this.getSerializable(key) as? T
|
||||
}
|
||||
|
||||
inline fun <reified T : Serializable> Intent.getSerialized(key: String): T? {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
|
||||
this.getSerializableExtra(key, T::class.java)
|
||||
else
|
||||
this.getSerializableExtra(key) as? T
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue