Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Looper
import android.os.Parcel
import android.os.Parcelable
import android.text.Spannable
import android.text.Spanned
Expand Down Expand Up @@ -82,6 +83,19 @@ inline val isMainThread: Boolean get() = Looper.getMainLooper() == Looper.myLoop
fun <T : Any> unsafeLazy(initializer: () -> T): Lazy<T> =
lazy(LazyThreadSafetyMode.NONE, initializer)

fun <T : Parcelable> T.deepClone(): T? {
var parcel: Parcel? = null
return try {
parcel = Parcel.obtain().also {
it.writeParcelable(this, 0)
it.setDataPosition(0)
}
parcel.readParcelable(this::class.java.classLoader)
} finally {
parcel?.recycle()
}
}

// ---------------------CharSequence-------------------------------//

operator fun String.times(@IntRange(from = 0) num: Int): String {
Expand Down