รายการส่วนขยาย KTX

androidx.activity

การขึ้นต่อกัน

ดึงดูด

dependencies {
    implementation "androidx.activity:activity-ktx:1.10.1"
}

Kotlin

dependencies {
    implementation("androidx.activity:activity-ktx:1.10.1")
}

ฟังก์ชันของส่วนขยาย

สำหรับ OnBackPressedDispatcher
OnBackPressedCallback OnBackPressedDispatcher.addCallback(owner: LifecycleOwner? = null, enabled: Boolean = true, onBackPressed: OnBackPressedCallback.() -> Unit)

สร้างและเพิ่ม OnBackPressedCallback ใหม่ที่เรียก onBackPressed ใน OnBackPressedCallback.handleOnBackPressed

สำหรับ ComponentActivity
Lazy<VM> ComponentActivity.viewModels(noinline factoryProducer: () -> ViewModelProvider.Factory = null)

แสดงผลตัวแทน Lazy เพื่อเข้าถึง ViewModel ของ ComponentActivity หากมีการระบุ factoryProducer ระบบจะใช้ ViewModelProvider.Factory ที่แสดงผลโดย factoryProducer เพื่อสร้าง ViewModel เป็นครั้งแรก

androidx.benchmark

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.benchmark:benchmark-junit4:1.4.0"
}

Kotlin

dependencies {
    implementation("androidx.benchmark:benchmark-junit4:1.4.0")
}

ฟังก์ชันระดับบนสุด

หน่วย beginTraceSection(sectionName: String)

หน่วย endTraceSection()

androidx.benchmark.junit4

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.benchmark:benchmark-junit4:1.4.0"
}

Kotlin

dependencies {
    implementation("androidx.benchmark:benchmark-junit4:1.4.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ BenchmarkRule
หน่วย BenchmarkRule.measureRepeated(crossinline block: BenchmarkRule.Scope.() -> Unit)

เปรียบเทียบประสิทธิภาพของโค้ดบล็อก

androidx.collection

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.collection:collection-ktx:1.5.0"
}

Kotlin

dependencies {
    implementation("androidx.collection:collection-ktx:1.5.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ LongSparseArray
ตัวดำเนินการ บูลีน LongSparseArray<T>.contains(key: Long)

แสดงค่าจริงหากคอลเล็กชันมี key

หน่วย LongSparseArray<T>.forEach(action: (key: Long, value: T) -> Unit)

ดำเนินการการดำเนินการที่ระบุสำหรับรายการคีย์/ค่าแต่ละรายการ

T LongSparseArray<T>.getOrDefault(key: Long, defaultValue: T)

แสดงผลค่าที่สอดคล้องกับ key หรือ defaultValue เมื่อไม่มี

T LongSparseArray<T>.getOrElse(key: Long, defaultValue: () -> T)

แสดงค่าที่สอดคล้องกับ key หรือจาก defaultValue เมื่อไม่มี

บูลีน LongSparseArray<T>.isNotEmpty()

แสดงค่าเป็นจริงเมื่อคอลเล็กชันมีองค์ประกอบ

LongIterator LongSparseArray<T>.keyIterator()

ส่งคืนตัววนซ้ำเหนือคีย์ของคอลเล็กชัน

operator LongSparseArray<T> LongSparseArray<T>.plus(other: LongSparseArray<T>)

สร้างคอลเล็กชันใหม่โดยการเพิ่มหรือแทนที่รายการจากอื่นๆ

บูลีน LongSparseArray<T>.remove(key: Long, value: T)

นำรายการสำหรับ key ออกก็ต่อเมื่อมีการแมปกับ value

โอเปอเรเตอร์ Unit LongSparseArray<T>.set(key: Long, value: T)

อนุญาตให้ใช้โอเปอเรเตอร์ดัชนีเพื่อจัดเก็บค่าในคอลเล็กชัน

Iterator<T> LongSparseArray<T>.valueIterator()

แสดงผลตัววนซ้ำเหนือค่าของคอลเล็กชัน

สำหรับ SparseArrayCompat
ตัวดำเนินการ บูลีน SparseArrayCompat<T>.contains(key: Int)

แสดงค่าจริงหากคอลเล็กชันมี key

หน่วย SparseArrayCompat<T>.forEach(action: (key: Int, value: T) -> Unit)

ดำเนินการการดำเนินการที่ระบุสำหรับรายการคีย์/ค่าแต่ละรายการ

T SparseArrayCompat<T>.getOrDefault(key: Int, defaultValue: T)

แสดงผลค่าที่สอดคล้องกับ key หรือ defaultValue เมื่อไม่มี

T SparseArrayCompat<T>.getOrElse(key: Int, defaultValue: () -> T)

แสดงค่าที่สอดคล้องกับ key หรือจาก defaultValue เมื่อไม่มี

บูลีน SparseArrayCompat<T>.isNotEmpty()

แสดงค่าเป็นจริงเมื่อคอลเล็กชันมีองค์ประกอบ

IntIterator SparseArrayCompat<T>.keyIterator()

ส่งคืนตัววนซ้ำเหนือคีย์ของคอลเล็กชัน

operator SparseArrayCompat<T> SparseArrayCompat<T>.plus(other: SparseArrayCompat<T>)

สร้างคอลเล็กชันใหม่โดยการเพิ่มหรือแทนที่รายการจากอื่นๆ

บูลีน SparseArrayCompat<T>.remove(key: Int, value: T)

นำรายการสำหรับ key ออกก็ต่อเมื่อมีการแมปกับ value

โอเปอเรเตอร์ Unit SparseArrayCompat<T>.set(key: Int, value: T)

อนุญาตให้ใช้โอเปอเรเตอร์ดัชนีเพื่อจัดเก็บค่าในคอลเล็กชัน

Iterator<T> SparseArrayCompat<T>.valueIterator()

แสดงผลตัววนซ้ำเหนือค่าของคอลเล็กชัน

คุณสมบัติของส่วนขยาย

สำหรับ LongSparseArray
Int LongSparseArray<T>.size()

แสดงผลจำนวนคู่คีย์/ค่าในคอลเล็กชัน

สำหรับ SparseArrayCompat
Int SparseArrayCompat<T>.size()

แสดงผลจำนวนคู่คีย์/ค่าในคอลเล็กชัน

ฟังก์ชันระดับบนสุด

ArrayMap< K, V> arrayMapOf()

แสดงผล ArrayMap ใหม่ที่ว่างเปล่า

ArrayMap< K, V> arrayMapOf(vararg pairs: Pair<K, V>)

แสดงผล ArrayMap ใหม่ที่มีเนื้อหาที่ระบุ ซึ่งระบุเป็นรายการคู่โดยที่คอมโพเนนต์แรกคือคีย์และคอมโพเนนต์ที่สองคือค่า

ArraySet<T> arraySetOf()

แสดงผล ArraySet ใหม่ที่ว่างเปล่า

ArraySet<T> arraySetOf(vararg values: T)

แสดงผล ArraySet ใหม่ที่มีเนื้อหาที่ระบุ

LruCache< K, V> lruCache(maxSize: Int, crossinline sizeOf: (key: K, value: V) -> Int = { _, _ -> 1 }, crossinline create: (key: K) -> V? = { null as V? }, crossinline onEntryRemoved: (evicted: Boolean, key: K, oldValue: V, newValue: V?) -> Unit = { _, _, _, _ -> })

สร้าง LruCache ด้วยพารามิเตอร์ที่ระบุ

androidx.core.animation

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.animation.Animator
AnimatorListener Animator.addListener(crossinline onEnd: (animator: Animator) -> Unit = {}, crossinline onStart: (animator: Animator) -> Unit = {}, crossinline onCancel: (animator: Animator) -> Unit = {}, crossinline onRepeat: (animator: Animator) -> Unit = {})

เพิ่ม Listener ลงใน Animator นี้โดยใช้การดำเนินการที่ระบุ

AnimatorPauseListener Animator.addPauseListener(crossinline onResume: (animator: Animator) -> Unit = {}, crossinline onPause: (animator: Animator) -> Unit = {})

เพิ่ม Listener สำหรับหยุดชั่วคราวและกลับมาทำงานต่อใน Animator นี้โดยใช้การดำเนินการที่ระบุ

AnimatorListener Animator.doOnCancel(crossinline action: (animator: Animator) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้เมื่อยกเลิกภาพเคลื่อนไหว

AnimatorListener Animator.doOnEnd(crossinline action: (animator: Animator) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้เมื่อภาพเคลื่อนไหวสิ้นสุดลง

AnimatorPauseListener Animator.doOnPause(crossinline action: (animator: Animator) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้เมื่อหยุดภาพเคลื่อนไหวชั่วคราว

AnimatorListener Animator.doOnRepeat(crossinline action: (animator: Animator) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้เมื่อภาพเคลื่อนไหวเล่นซ้ำ

AnimatorPauseListener Animator.doOnResume(crossinline action: (animator: Animator) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้เมื่อภาพเคลื่อนไหวกลับมาเล่นอีกครั้งหลังจากหยุดชั่วคราว

AnimatorListener Animator.doOnStart(crossinline action: (animator: Animator) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้เมื่อภาพเคลื่อนไหวเริ่มขึ้น

androidx.core.content

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.content.Context
T? Context.getSystemService()

ส่งคืนแฮนเดิลไปยังบริการระดับระบบตามคลาส

หน่วย Context.withStyledAttributes(set: AttributeSet? = null, attrs: IntArray, @AttrRes defStyleAttr: Int = 0, @StyleRes defStyleRes: Int = 0, block: TypedArray.() -> Unit)

ดำเนินการบล็อกในตัวรับ TypedArray

หน่วย Context.withStyledAttributes(@StyleRes resourceId: Int, attrs: IntArray, block: TypedArray.() -> Unit)

ดำเนินการบล็อกในตัวรับ TypedArray

สำหรับ android.content.SharedPreferences
หน่วย SharedPreferences.edit(commit: Boolean = false, action: Editor.() -> Unit)

อนุญาตให้แก้ไขอินสแตนซ์ค่ากำหนดนี้ด้วยการเรียกใช้ apply หรือ commit เพื่อบันทึกการเปลี่ยนแปลง

ฟังก์ชันระดับบนสุด

ContentValues contentValuesOf(vararg pairs: Pair<String, Any?>)

แสดงผล ContentValues ใหม่ที่มีคู่คีย์/ค่าที่ระบุเป็นองค์ประกอบ

androidx.core.content.res

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.content.res.TypedArray
บูลีน TypedArray.getBooleanOrThrow(@StyleableRes index: Int)

เรียกค่าบูลีนสำหรับแอตทริบิวต์ที่ดัชนี หรือส่ง IllegalArgumentException หากไม่ได้กำหนด

Int TypedArray.getColorOrThrow(@StyleableRes index: Int)

เรียกค่าสีสำหรับแอตทริบิวต์ที่ index หรือส่ง IllegalArgumentException หากไม่ได้กำหนด

ColorStateList TypedArray.getColorStateListOrThrow(@StyleableRes index: Int)

เรียกค่ารายการสถานะสีสำหรับแอตทริบิวต์ที่ดัชนีหรือส่งIllegalArgumentException หากไม่ได้กำหนดไว้

ลอย TypedArray.getDimensionOrThrow(@StyleableRes index: Int)

เรียกค่ามิติข้อมูลสำหรับแอตทริบิวต์ที่ดัชนี หรือส่ง IllegalArgumentException หากไม่ได้กำหนดไว้

Int TypedArray.getDimensionPixelOffsetOrThrow(@StyleableRes index: Int)

เรียกค่าออฟเซ็ตพิกเซลของมิติข้อมูลสำหรับแอตทริบิวต์ที่ index หรือส่ง IllegalArgumentException หากไม่ได้กำหนด

Int TypedArray.getDimensionPixelSizeOrThrow(@StyleableRes index: Int)

เรียกค่าขนาดพิกเซลของมิติข้อมูลสำหรับแอตทริบิวต์ที่ index หรือส่ง IllegalArgumentException หากไม่ได้กำหนด

Drawable TypedArray.getDrawableOrThrow(@StyleableRes index: Int)

เรียกค่า Drawable สำหรับแอตทริบิวต์ที่ index หรือส่ง IllegalArgumentException หากไม่ได้กำหนด

ลอย TypedArray.getFloatOrThrow(@StyleableRes index: Int)

เรียกค่าลอยสำหรับแอตทริบิวต์ที่ index หรือส่ง IllegalArgumentException หากไม่ได้กำหนด

แบบอักษร TypedArray.getFontOrThrow(@StyleableRes index: Int)

เรียกค่าแบบอักษรสำหรับแอตทริบิวต์ที่index หรือส่ง IllegalArgumentException หากไม่ได้กำหนดไว้

Int TypedArray.getIntOrThrow(@StyleableRes index: Int)

เรียกค่าจำนวนเต็มสำหรับแอตทริบิวต์ที่ index หรือส่ง IllegalArgumentException หากไม่ได้กำหนดไว้

Int TypedArray.getIntegerOrThrow(@StyleableRes index: Int)

เรียกค่าจำนวนเต็มสำหรับแอตทริบิวต์ที่ index หรือส่ง IllegalArgumentException หากไม่ได้กำหนดไว้

Int TypedArray.getResourceIdOrThrow(@StyleableRes index: Int)

เรียกตัวระบุทรัพยากรสำหรับแอตทริบิวต์ที่ดัชนี หรือส่ง IllegalArgumentException หากไม่ได้กำหนดไว้

สตริง TypedArray.getStringOrThrow(@StyleableRes index: Int)

เรียกค่าสตริงสำหรับแอตทริบิวต์ที่ index หรือส่ง IllegalArgumentException หากไม่ได้กำหนด

Array<CharSequence> TypedArray.getTextArrayOrThrow(@StyleableRes index: Int)

เรียกค่าอาร์เรย์ข้อความสำหรับแอตทริบิวต์ที่ดัชนี หรือส่ง IllegalArgumentException หากไม่ได้กำหนด

CharSequence TypedArray.getTextOrThrow(@StyleableRes index: Int)

เรียกค่าข้อความสำหรับแอตทริบิวต์ที่ index หรือส่ง IllegalArgumentException หากไม่ได้กำหนด

R TypedArray.use(block: (TypedArray) -> R)

เรียกใช้ฟังก์ชัน block ที่ระบุใน TypedArray นี้ แล้วรีไซเคิล

androidx.core.database

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.database.Cursor
ByteArray Cursor.getBlobOrNull(index: Int)

แสดงผลค่าของคอลัมน์ที่ขอเป็นอาร์เรย์ไบต์ที่อนุญาตให้เป็น Null

Double Cursor.getDoubleOrNull(index: Int)

แสดงผลค่าของคอลัมน์ที่ขอเป็น Double ที่อนุญาตให้เป็น Null

ลอยใช่ไหม Cursor.getFloatOrNull(index: Int)

แสดงผลค่าของคอลัมน์ที่ขอเป็นค่าลอยที่อนุญาตให้เป็น Null

Int Cursor.getIntOrNull(index: Int)

แสดงผลค่าของคอลัมน์ที่ขอเป็นจำนวนเต็มที่อนุญาตให้เป็น Null

ยาว Cursor.getLongOrNull(index: Int)

แสดงผลค่าของคอลัมน์ที่ขอเป็นแบบยาวที่อนุญาตให้เป็น Null

Short Cursor.getShortOrNull(index: Int)

แสดงผลค่าของคอลัมน์ที่ขอเป็น Short ที่อนุญาตให้เป็น Null

สตริง? Cursor.getStringOrNull(index: Int)

แสดงผลค่าของคอลัมน์ที่ขอเป็นสตริงที่อนุญาตให้เป็น Null

androidx.core.database.sqlite

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.database.sqlite.SQLiteDatabase
T SQLiteDatabase.transaction(exclusive: Boolean = true, body: SQLiteDatabase.() -> T)

เรียกใช้ body ในธุรกรรมโดยทำเครื่องหมายว่าสำเร็จหากเสร็จสมบูรณ์โดยไม่มีข้อยกเว้น

androidx.core.graphics

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.graphics.Bitmap
บิตแมป Bitmap.applyCanvas(block: Canvas.() -> Unit)

สร้าง Canvas ใหม่เพื่อวาดบนบิตแมปนี้และเรียกใช้บล็อกที่ระบุใน Canvas ที่สร้างขึ้นใหม่

ตัวดำเนินการ บูลีน Bitmap.contains(p: Point)

แสดงค่าเป็น "จริง" หากจุดที่ระบุอยู่ภายในบิตแมป

ตัวดำเนินการ บูลีน Bitmap.contains(p: PointF)

แสดงค่าเป็น "จริง" หากจุดที่ระบุอยู่ภายในบิตแมป

operator Int Bitmap.get(x: Int, y: Int)

แสดงค่าของพิกเซลในตำแหน่งที่ระบุ

บิตแมป Bitmap.scale(width: Int, height: Int, filter: Boolean = true)

สร้างบิตแมปใหม่ที่ปรับขนาดจากบิตแมปนี้เมื่อเป็นไปได้

โอเปอเรเตอร์ Unit Bitmap.set(x: Int, y: Int, color: Int)

เขียน color int ที่ระบุลงในบิตแมป (สมมติว่าบิตแมปเปลี่ยนแปลงได้) ที่พิกัด (x, y) ที่ระบุ

สำหรับ android.graphics.Canvas
หน่วย Canvas.withClip(clipRect: Rect, block: Canvas.() -> Unit)

ห่อหุ้มบล็อกที่ระบุในการเรียกใช้ Canvas.save/Canvas.clipRect และ Canvas.restoreToCount

หน่วย Canvas.withClip(clipRect: RectF, block: Canvas.() -> Unit)

ห่อหุ้มบล็อกที่ระบุในการเรียกใช้ Canvas.save/Canvas.clipRect และ Canvas.restoreToCount

หน่วย Canvas.withClip(left: Int, top: Int, right: Int, bottom: Int, block: Canvas.() -> Unit)

ห่อหุ้มบล็อกที่ระบุในการเรียกใช้ Canvas.save/Canvas.clipRect และ Canvas.restoreToCount

หน่วย Canvas.withClip(left: Float, top: Float, right: Float, bottom: Float, block: Canvas.() -> Unit)

ห่อหุ้มบล็อกที่ระบุในการเรียกใช้ Canvas.save/Canvas.clipRect และ Canvas.restoreToCount

หน่วย Canvas.withClip(clipPath: Path, block: Canvas.() -> Unit)

ห่อหุ้มบล็อกที่ระบุในการเรียกใช้ Canvas.save/Canvas.clipPath และ Canvas.restoreToCount

หน่วย Canvas.withMatrix(matrix: Matrix = Matrix(), block: Canvas.() -> Unit)

ห่อหุ้มบล็อกที่ระบุในการเรียกใช้ Canvas.save/Canvas.concat และ Canvas.restoreToCount

หน่วย Canvas.withRotation(degrees: Float = 0.0f, pivotX: Float = 0.0f, pivotY: Float = 0.0f, block: Canvas.() -> Unit)

ห่อหุ้มบล็อกที่ระบุในการเรียกใช้ Canvas.save/Canvas.rotate และ Canvas.restoreToCount

หน่วย Canvas.withSave(block: Canvas.() -> Unit)

ห่อหุ้มบล็อกที่ระบุในการเรียกใช้ Canvas.save และ Canvas.restoreToCount

หน่วย Canvas.withScale(x: Float = 1.0f, y: Float = 1.0f, pivotX: Float = 0.0f, pivotY: Float = 0.0f, block: Canvas.() -> Unit)

ห่อหุ้มบล็อกที่ระบุในการเรียกใช้ Canvas.save/Canvas.scale และ Canvas.restoreToCount

หน่วย Canvas.withSkew(x: Float = 0.0f, y: Float = 0.0f, block: Canvas.() -> Unit)

ห่อหุ้มบล็อกที่ระบุในการเรียกใช้ Canvas.save/Canvas.skew และ Canvas.restoreToCount

หน่วย Canvas.withTranslation(x: Float = 0.0f, y: Float = 0.0f, block: Canvas.() -> Unit)

ห่อหุ้มบล็อกที่ระบุในการเรียกใช้ Canvas.save/Canvas.translate และ Canvas.restoreToCount

สำหรับ android.graphics.Color
โอเปอเรเตอร์ Float Color.component1()

แสดงผลคอมโพเนนต์แรกของสี

โอเปอเรเตอร์ Float Color.component2()

แสดงผลคอมโพเนนต์ที่ 2 ของสี

โอเปอเรเตอร์ Float Color.component3()

แสดงผลคอมโพเนนต์ที่ 3 ของสี

โอเปอเรเตอร์ Float Color.component4()

แสดงผลคอมโพเนนต์ที่ 4 ของสี

infix Color! Color.convertTo(colorSpace: Named)

แปลงตัวรับสีเป็นสีในพื้นที่สีที่ระบุ

infix Color! Color.convertTo(colorSpace: ColorSpace)

แปลงตัวรับสีเป็นสีในพื้นที่สีที่ระบุ

โอเปอเรเตอร์ สี Color.plus(c: Color)

รวมสีโปร่งแสง 2 สีเข้าด้วยกัน

สำหรับ android.graphics.ImageDecoder.Source
บิตแมป Source.decodeBitmap(crossinline action: ImageDecoder.(info: ImageInfo, source: Source) -> Unit)

สร้างบิตแมปจากแหล่งที่มา

Drawable Source.decodeDrawable(crossinline action: ImageDecoder.(info: ImageInfo, source: Source) -> Unit)

สร้าง Drawable จากแหล่งที่มา

สำหรับ android.graphics.Matrix
operator Matrix Matrix.times(m: Matrix)

คูณเมทริกซ์นี้กับเมทริกซ์อื่นและแสดงผลลัพธ์เป็น เมทริกซ์ใหม่

FloatArray Matrix.values()

แสดงผลค่า 9 ค่าของเมทริกซ์นี้เป็นอาร์เรย์ใหม่ของค่าทศนิยม

สำหรับ android.graphics.Paint
บูลีน Paint.setBlendMode(blendModeCompat: BlendModeCompat?)

วิธีที่สะดวกในการกำหนดค่า BlendMode ของ Paint ในลักษณะที่เข้ากันได้แบบย้อนหลัง

สำหรับ android.graphics.Path
infix Path Path.and(p: Path)

แสดงผลอินเตอร์เซกชันของ 2 เส้นทางเป็นเส้นทางใหม่

Iterable<PathSegment> Path.flatten(error: Float = 0.5f)

ทำให้เส้นทางแบนราบ (หรือโดยประมาณ) ด้วยชุดของส่วนเส้นตรง

โอเปอเรเตอร์ เส้นทาง Path.minus(p: Path)

แสดงผลส่วนต่างของเส้นทาง 2 เส้นทางเป็นเส้นทางใหม่

infix Path Path.or(p: Path)

แสดงผลการรวมเส้นทาง 2 เส้นทางเป็น Path ใหม่

โอเปอเรเตอร์ เส้นทาง Path.plus(p: Path)

แสดงผลการรวมเส้นทาง 2 เส้นทางเป็น Path ใหม่

infix Path Path.xor(p: Path)

แสดงผลยูเนียนลบด้วยอินเตอร์เซกชันของ 2 เส้นทางเป็น Path ใหม่

สำหรับ android.graphics.Picture
รูปภาพ Picture.record(width: Int, height: Int, block: Canvas.() -> Unit)

สร้าง Canvas ใหม่เพื่อบันทึกคำสั่งในรูปภาพนี้ เรียกใช้บล็อกที่ระบุใน Canvas ที่สร้างขึ้นใหม่ และแสดงผลรูปภาพนี้

สำหรับ android.graphics.Point
operator Int Point.component1()

แสดงผลพิกัด x ของจุดนี้

operator Int Point.component2()

แสดงผลพิกัด y ของจุดนี้

โอเปอเรเตอร์ Point Point.minus(p: Point)

ออฟเซ็ตจุดนี้ด้วยการนิเสธของจุดที่ระบุและแสดงผลลัพธ์ เป็นจุดใหม่

โอเปอเรเตอร์ Point Point.minus(xy: Int)

ชดเชยจุดนี้ด้วยค่าที่ระบุในแกน X และ Y และ แสดงผลลัพธ์เป็นจุดใหม่

โอเปอเรเตอร์ Point Point.plus(p: Point)

ออฟเซ็ตจุดนี้ตามจุดที่ระบุและแสดงผลลัพธ์เป็นจุดใหม่

โอเปอเรเตอร์ Point Point.plus(xy: Int)

ชดเชยจุดนี้ตามจำนวนที่ระบุไว้ทั้งในแกน X และแกน Y แล้วส่งคืนผลลัพธ์เป็นจุดใหม่

PointF Point.toPointF()

แสดงการแทนค่า PointF ของจุดนี้

โอเปอเรเตอร์ Point Point.unaryMinus()

แสดงผลจุดใหม่ที่แสดงถึงการนิเสธของจุดนี้

สำหรับ android.graphics.PointF
โอเปอเรเตอร์ Float PointF.component1()

แสดงผลพิกัด x ของจุดนี้

โอเปอเรเตอร์ Float PointF.component2()

แสดงผลพิกัด y ของจุดนี้

operator PointF PointF.minus(p: PointF)

ออฟเซ็ตจุดนี้ด้วยการนิเสธของจุดที่ระบุและแสดงผลลัพธ์ เป็นจุดใหม่

operator PointF PointF.minus(xy: Float)

ชดเชยจุดนี้ด้วยค่าที่ระบุในแกน X และ Y และ แสดงผลลัพธ์เป็นจุดใหม่

operator PointF PointF.plus(p: PointF)

ออฟเซ็ตจุดนี้ตามจุดที่ระบุและแสดงผลลัพธ์เป็นจุดใหม่

operator PointF PointF.plus(xy: Float)

ชดเชยจุดนี้ตามจำนวนที่ระบุไว้ทั้งในแกน X และแกน Y แล้วส่งคืนผลลัพธ์เป็นจุดใหม่

Point PointF.toPoint()

แสดงผลการแทนค่า Point ของจุดนี้

operator PointF PointF.unaryMinus()

แสดงผลจุดใหม่ที่แสดงถึงการนิเสธของจุดนี้

สำหรับ android.graphics.PorterDuff.Mode
PorterDuffColorFilter Mode.toColorFilter(color: Int)

สร้าง PorterDuffColorFilter ใหม่ที่ใช้ PorterDuff.Mode นี้เป็น โหมดการวางซ้อนหรือการผสมอัลฟ่า และสีที่ระบุ

PorterDuffXfermode Mode.toXfermode()

สร้าง PorterDuffXfermode ใหม่ที่ใช้ PorterDuff.Mode นี้เป็น โหมดการวางซ้อนหรือการผสมอัลฟ่า

สำหรับ android.graphics.Rect
infix Rect Rect.and(r: Rect)

แสดงผลอินเทอร์เซกชันของสี่เหลี่ยมผืนผ้า 2 รูปเป็นสี่เหลี่ยมผืนผ้าใหม่

operator Int Rect.component1()

แสดงผล "left" ซึ่งเป็นคอมโพเนนต์แรกของสี่เหลี่ยมผืนผ้า

operator Int Rect.component2()

แสดงผล "top" ซึ่งเป็นคอมโพเนนต์ที่ 2 ของสี่เหลี่ยมผืนผ้า

operator Int Rect.component3()

แสดงผล "right" ซึ่งเป็นคอมโพเนนต์ที่ 3 ของสี่เหลี่ยมผืนผ้า

operator Int Rect.component4()

แสดงผล "bottom" ซึ่งเป็นคอมโพเนนต์ที่ 4 ของสี่เหลี่ยมผืนผ้า

ตัวดำเนินการ บูลีน Rect.contains(p: Point)

แสดงค่าเป็นจริงหากจุดที่ระบุอยู่ภายในสี่เหลี่ยมผืนผ้า

โอเปอเรเตอร์ ภูมิภาค Rect.minus(r: Rect)

แสดงผลความแตกต่างของสี่เหลี่ยมผืนผ้านี้และสี่เหลี่ยมผืนผ้าที่ระบุเป็นภูมิภาคใหม่

operator Rect Rect.minus(xy: Int)

แสดงผลสี่เหลี่ยมผืนผ้าใหม่ซึ่งแสดงถึงสี่เหลี่ยมผืนผ้านี้ที่ออฟเซ็ตด้วยค่าที่ระบุ ในแกน X และ Y

operator Rect Rect.minus(xy: Point)

แสดงผลสี่เหลี่ยมผืนผ้าใหม่ที่แสดงถึงสี่เหลี่ยมผืนผ้านี้ซึ่งออฟเซ็ตด้วยค่าลบของ จุดที่ระบุ

infix Rect Rect.or(r: Rect)

แสดงผลการรวมสี่เหลี่ยมผืนผ้า 2 รูปเป็นสี่เหลี่ยมผืนผ้าใหม่

operator Rect Rect.plus(r: Rect)

รวมสี่เหลี่ยมผืนผ้านี้กับสี่เหลี่ยมผืนผ้าที่ระบุและแสดงผลลัพธ์เป็นสี่เหลี่ยมผืนผ้าใหม่

operator Rect Rect.plus(xy: Int)

แสดงผลสี่เหลี่ยมผืนผ้าใหม่ที่แสดงถึงสี่เหลี่ยมผืนผ้านี้ซึ่งออฟเซ็ตตาม จำนวนที่ระบุทั้งบนแกน X และแกน Y

operator Rect Rect.plus(xy: Point)

แสดงผลสี่เหลี่ยมผืนผ้าใหม่ที่แสดงถึงสี่เหลี่ยมผืนผ้านี้ซึ่งออฟเซ็ตด้วย จุดที่ระบุ

operator Rect Rect.times(factor: Int)

แสดงผลสี่เหลี่ยมผืนผ้าใหม่ที่แสดงถึงคอมโพเนนต์ของสี่เหลี่ยมผืนผ้านี้ โดยแต่ละคอมโพเนนต์จะปรับขนาดตามแฟกเตอร์

RectF Rect.toRectF()

แสดงผลการแสดง RectF ของสี่เหลี่ยมผืนผ้านี้

ภูมิภาค Rect.toRegion()

แสดงผลการแสดง Region ของสี่เหลี่ยมผืนผ้านี้

คำต่อท้าย ภูมิภาค Rect.xor(r: Rect)

แสดงผลยูเนียนลบอินเตอร์เซกชันของสี่เหลี่ยมผืนผ้า 2 รูปเป็นภูมิภาคใหม่

สำหรับ android.graphics.RectF
infix RectF RectF.and(r: RectF)

แสดงผลอินเทอร์เซกชันของสี่เหลี่ยมผืนผ้า 2 รูปเป็นสี่เหลี่ยมผืนผ้าใหม่

โอเปอเรเตอร์ Float RectF.component1()

แสดงผล "left" ซึ่งเป็นคอมโพเนนต์แรกของสี่เหลี่ยมผืนผ้า

โอเปอเรเตอร์ Float RectF.component2()

แสดงผล "top" ซึ่งเป็นคอมโพเนนต์ที่ 2 ของสี่เหลี่ยมผืนผ้า

โอเปอเรเตอร์ Float RectF.component3()

แสดงผล "right" ซึ่งเป็นคอมโพเนนต์ที่ 3 ของสี่เหลี่ยมผืนผ้า

โอเปอเรเตอร์ Float RectF.component4()

แสดงผล "bottom" ซึ่งเป็นคอมโพเนนต์ที่ 4 ของสี่เหลี่ยมผืนผ้า

ตัวดำเนินการ บูลีน RectF.contains(p: PointF)

แสดงค่าเป็นจริงหากจุดที่ระบุอยู่ภายในสี่เหลี่ยมผืนผ้า

โอเปอเรเตอร์ ภูมิภาค RectF.minus(r: RectF)

แสดงผลความแตกต่างของสี่เหลี่ยมผืนผ้านี้และสี่เหลี่ยมผืนผ้าที่ระบุเป็นภูมิภาคใหม่

operator RectF RectF.minus(xy: Float)

แสดงผลสี่เหลี่ยมผืนผ้าใหม่ซึ่งแสดงถึงสี่เหลี่ยมผืนผ้านี้ที่ออฟเซ็ตด้วยค่าที่ระบุ ในแกน X และ Y

operator RectF RectF.minus(xy: PointF)

แสดงผลสี่เหลี่ยมผืนผ้าใหม่ที่แสดงถึงสี่เหลี่ยมผืนผ้านี้ซึ่งออฟเซ็ตด้วยค่าลบของ จุดที่ระบุ

infix RectF RectF.or(r: RectF)

แสดงผลการรวมสี่เหลี่ยมผืนผ้า 2 รูปเป็นสี่เหลี่ยมผืนผ้าใหม่

operator RectF RectF.plus(r: RectF)

รวมสี่เหลี่ยมผืนผ้านี้กับสี่เหลี่ยมผืนผ้าที่ระบุและแสดงผลลัพธ์เป็นสี่เหลี่ยมผืนผ้าใหม่

operator RectF RectF.plus(xy: Float)

แสดงผลสี่เหลี่ยมผืนผ้าใหม่ที่แสดงถึงสี่เหลี่ยมผืนผ้านี้ซึ่งออฟเซ็ตตาม จำนวนที่ระบุทั้งบนแกน X และแกน Y

operator RectF RectF.plus(xy: PointF)

แสดงผลสี่เหลี่ยมผืนผ้าใหม่ที่แสดงถึงสี่เหลี่ยมผืนผ้านี้ซึ่งออฟเซ็ตด้วย จุดที่ระบุ

operator RectF RectF.times(factor: Int)

แสดงผลสี่เหลี่ยมผืนผ้าใหม่ที่แสดงถึงคอมโพเนนต์ของสี่เหลี่ยมผืนผ้านี้ โดยแต่ละคอมโพเนนต์จะปรับขนาดตามแฟกเตอร์

operator RectF RectF.times(factor: Float)

แสดงผลสี่เหลี่ยมผืนผ้าใหม่ที่แสดงถึงคอมโพเนนต์ของสี่เหลี่ยมผืนผ้านี้ โดยแต่ละคอมโพเนนต์จะปรับขนาดตามแฟกเตอร์

Rect RectF.toRect()

แสดงผลการแทนค่า Rect ของสี่เหลี่ยมผืนผ้านี้

ภูมิภาค RectF.toRegion()

แสดงผลการแสดง Region ของสี่เหลี่ยมผืนผ้านี้

RectF RectF.transform(m: Matrix)

แปลงรูปสี่เหลี่ยมผืนผ้านี้ในตำแหน่งโดยใช้ Matrix ที่ระบุและส่งคืน รูปสี่เหลี่ยมผืนผ้านี้

คำต่อท้าย ภูมิภาค RectF.xor(r: RectF)

แสดงผลยูเนียนลบอินเตอร์เซกชันของสี่เหลี่ยมผืนผ้า 2 รูปเป็นภูมิภาคใหม่

สำหรับ android.graphics.Region
คำต่อท้าย ภูมิภาค Region.and(r: Rect)

แสดงผลส่วนที่ทับซ้อนกันของภูมิภาคนี้และ Rect ที่ระบุเป็นภูมิภาคใหม่

คำต่อท้าย ภูมิภาค Region.and(r: Region)

แสดงผลส่วนที่ทับซ้อนกันของภูมิภาคนี้และภูมิภาคที่ระบุเป็นภูมิภาคใหม่

ตัวดำเนินการ บูลีน Region.contains(p: Point)

แสดงค่าเป็นจริงหากภูมิภาคมี Point ที่ระบุ

หน่วย Region.forEach(action: (rect: Rect) -> Unit)

ดำเนินการที่ระบุในแต่ละสี่เหลี่ยมผืนผ้าในภูมิภาคนี้

operator Iterator<Rect> Region.iterator()

แสดงผล Iterator เหนือสี่เหลี่ยมผืนผ้าในภูมิภาคนี้

โอเปอเรเตอร์ ภูมิภาค Region.minus(r: Rect)

แสดงผลความแตกต่างของภูมิภาคนี้และ Rect ที่ระบุเป็นภูมิภาคใหม่

โอเปอเรเตอร์ ภูมิภาค Region.minus(r: Region)

แสดงผลความแตกต่างของภูมิภาคนี้กับภูมิภาคที่ระบุเป็นภูมิภาคใหม่

โอเปอเรเตอร์ ภูมิภาค Region.not()

แสดงการปฏิเสธของภูมิภาคนี้เป็นภูมิภาคใหม่

คำต่อท้าย ภูมิภาค Region.or(r: Rect)

แสดงผลการรวมของภูมิภาคนี้และ Rect ที่ระบุเป็นภูมิภาคใหม่

คำต่อท้าย ภูมิภาค Region.or(r: Region)

แสดงผลการรวมของภูมิภาคนี้และภูมิภาคที่ระบุเป็นภูมิภาคใหม่

โอเปอเรเตอร์ ภูมิภาค Region.plus(r: Rect)

แสดงผลการรวมของภูมิภาคนี้และ Rect ที่ระบุเป็นภูมิภาคใหม่

โอเปอเรเตอร์ ภูมิภาค Region.plus(r: Region)

แสดงผลการรวมของภูมิภาคนี้และภูมิภาคที่ระบุเป็นภูมิภาคใหม่

โอเปอเรเตอร์ ภูมิภาค Region.unaryMinus()

แสดงการปฏิเสธของภูมิภาคนี้เป็นภูมิภาคใหม่

คำต่อท้าย ภูมิภาค Region.xor(r: Rect)

แสดงผลยูเนียนลบด้วยอินเทอร์เซกชันของภูมิภาคนี้และ Rect ที่ระบุเป็นภูมิภาคใหม่

คำต่อท้าย ภูมิภาค Region.xor(r: Region)

แสดงผลยูเนียนลบอินเตอร์เซกชันของภูมิภาคนี้และภูมิภาคที่ระบุ เป็นภูมิภาคใหม่

สำหรับ android.graphics.Shader
หน่วย Shader.transform(block: Matrix.() -> Unit)

ห่อหุ้มบล็อกที่ระบุในการเรียกใช้ Shader.getLocalMatrix และ Shader.setLocalMatrix

สำหรับ kotlin.Int
operator Int Int.component1()

แสดงผลคอมโพเนนต์อัลฟ่าของจำนวนเต็มสี

operator Int Int.component2()

แสดงผลคอมโพเนนต์สีแดงของจำนวนเต็มสี

operator Int Int.component3()

แสดงผลคอมโพเนนต์สีเขียวของจำนวนเต็มสี

operator Int Int.component4()

แสดงผลคอมโพเนนต์สีน้ำเงินของจำนวนเต็มสี

infix Long Int.convertTo(colorSpace: Named)

แปลงตัวรับสี int เป็นสี long ในพื้นที่สีที่ระบุ

infix Long Int.convertTo(colorSpace: ColorSpace)

แปลงตัวรับสี int เป็นสี long ในพื้นที่สีที่ระบุ

สี Int.toColor()

สร้างอินสแตนซ์ Color ใหม่จากจำนวนเต็มของสี

ยาว Int.toColorLong()

แปลง color int ของ ARGB ที่ระบุเป็น color long ของ RGBA ในพื้นที่สี sRGB

สำหรับ kotlin.Long
โอเปอเรเตอร์ Float Long.component1()

แสดงผลคอมโพเนนต์แรกของสี

โอเปอเรเตอร์ Float Long.component2()

แสดงผลคอมโพเนนต์ที่ 2 ของสี

โอเปอเรเตอร์ Float Long.component3()

แสดงผลคอมโพเนนต์ที่ 3 ของสี

โอเปอเรเตอร์ Float Long.component4()

แสดงผลคอมโพเนนต์ที่ 4 ของสี

infix Long Long.convertTo(colorSpace: Named)

แปลงตัวรับสัญญาณสีแบบยาวเป็นสีแบบยาวในพื้นที่สีที่ระบุ

infix Long Long.convertTo(colorSpace: ColorSpace)

แปลงตัวรับสัญญาณสีแบบยาวเป็นสีแบบยาวในพื้นที่สีที่ระบุ

สี Long.toColor()

สร้างอินสแตนซ์ Color ใหม่จาก color long

Int Long.toColorInt()

แปลงสีแบบยาวที่ระบุเป็นสีแบบ int ของ ARGB

สำหรับ kotlin.String
Int String.toColorInt()

แสดงผลสี Int ที่สอดคล้องกับ String นี้

คุณสมบัติของส่วนขยาย

สำหรับ kotlin.Int
Int Int.alpha()

แสดงผลคอมโพเนนต์อัลฟ่าของจำนวนเต็มสี

Int Int.blue()

แสดงผลคอมโพเนนต์สีน้ำเงินของจำนวนเต็มสี

Int Int.green()

แสดงผลคอมโพเนนต์สีเขียวของจำนวนเต็มสี

ลอย Int.luminance()

แสดงผลความส่องสว่างสัมพัทธ์ของสี int โดยถือว่ามีการเข้ารหัส sRGB

Int Int.red()

แสดงผลคอมโพเนนต์สีแดงของจำนวนเต็มสี

สำหรับ kotlin.Long
ลอย Long.alpha()

แสดงผลคอมโพเนนต์อัลฟ่าของสีแบบยาว

ลอย Long.blue()

แสดงผลคอมโพเนนต์สีน้ำเงินของสีแบบยาว

ColorSpace Long.colorSpace()

แสดงผลพื้นที่สีที่เข้ารหัสในค่าสีแบบยาวที่ระบุ

ลอย Long.green()

แสดงผลคอมโพเนนต์สีเขียวของสีแบบยาว

บูลีน Long.isSrgb()

ระบุว่าสีอยู่ในพื้นที่สี sRGB หรือไม่

บูลีน Long.isWideGamut()

ระบุว่าสีอยู่ในพื้นที่สีช่วงกว้างหรือไม่

ลอย Long.luminance()

แสดงผลความสว่างสัมพัทธ์ของสี

ลอย Long.red()

แสดงผลคอมโพเนนต์สีแดงของสีแบบยาว

ฟังก์ชันระดับบนสุด

บิตแมป createBitmap(width: Int, height: Int, config: Config = Bitmap.Config.ARGB_8888)

แสดงผลบิตแมปที่เปลี่ยนแปลงได้ซึ่งมีความกว้างและความสูงที่ระบุ

บิตแมป createBitmap(width: Int, height: Int, config: Config = Bitmap.Config.ARGB_8888, hasAlpha: Boolean = true, colorSpace: ColorSpace = ColorSpace.get(ColorSpace.Named.SRGB))

แสดงผลบิตแมปที่เปลี่ยนแปลงได้ซึ่งมีความกว้างและความสูงที่ระบุ

เมทริกซ์ rotationMatrix(degrees: Float, px: Float = 0.0f, py: Float = 0.0f)

สร้างเมทริกซ์การหมุนที่กำหนดโดยมุมการหมุนเป็นองศารอบจุดหมุน ซึ่งอยู่ที่พิกัด (px, py)

เมทริกซ์ scaleMatrix(sx: Float = 1.0f, sy: Float = 1.0f)

สร้างเมทริกซ์การปรับขนาดที่มีปัจจัยการปรับขนาด sx และ sy ตามลำดับบนแกน x และ y

เมทริกซ์ translationMatrix(tx: Float = 0.0f, ty: Float = 0.0f)

สร้างเมทริกซ์การแปลที่มีจำนวนการแปล tx และ ty ตามลำดับบนแกน x และ y

androidx.core.graphics.drawable

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.graphics.Bitmap
ไอคอน Bitmap.toAdaptiveIcon()

สร้างไอคอนจากบิตแมปแบบปรับอัตโนมัตินี้

BitmapDrawable Bitmap.toDrawable(resources: Resources)

สร้าง BitmapDrawable จาก Bitmap นี้

ไอคอน Bitmap.toIcon()

สร้างไอคอนจากบิตแมปนี้

สำหรับ android.graphics.Color
ColorDrawable Color.toDrawable()

สร้าง ColorDrawable จาก Color นี้ (ผ่าน Color.toArgb)

สำหรับ android.graphics.drawable.Drawable
บิตแมป Drawable.toBitmap(@Px width: Int = intrinsicWidth, @Px height: Int = intrinsicHeight, config: Config? = null)

แสดงการแทน Bitmap ของ Drawable นี้

หน่วย Drawable.updateBounds(@Px left: Int = bounds.left, @Px top: Int = bounds.top, @Px right: Int = bounds.right, @Px bottom: Int = bounds.bottom)

อัปเดตขอบเขตของ Drawable นี้

สำหรับ android.net.Uri
ไอคอน Uri.toIcon()

สร้างไอคอนจาก Uri นี้

สำหรับ kotlin.ByteArray
ไอคอน ByteArray.toIcon()

สร้างไอคอนจาก ByteArray นี้

สำหรับ kotlin.Int
ColorDrawable Int.toDrawable()

สร้าง ColorDrawable จากค่าสีนี้

androidx.core.location

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.location.Location
โอเปอเรเตอร์ Double Location.component1()

แสดงผลละติจูดของ Location นี้

โอเปอเรเตอร์ Double Location.component2()

แสดงผลลองจิจูดของ Location นี้

androidx.core.net

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.net.Uri
ไฟล์ Uri.toFile()

สร้างไฟล์จาก Uri ที่ระบุ

สำหรับ java.io.File
Uri File.toUri()

สร้าง Uri จากไฟล์ที่ระบุ

สำหรับ kotlin.String
Uri String.toUri()

สร้าง Uri จากสตริง URI ที่เข้ารหัสที่ระบุ

androidx.core.os

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.os.Handler
Runnable Handler.postAtTime(uptimeMillis: Long, token: Any? = null, crossinline action: () -> Unit)

เวอร์ชันของ Handler.postAtTime ซึ่งจัดเรียงพารามิเตอร์ใหม่เพื่อให้วางการดำเนินการนอกวงเล็บได้

Runnable Handler.postDelayed(delayInMillis: Long, token: Any? = null, crossinline action: () -> Unit)

เวอร์ชันของ Handler.postDelayed ซึ่งจัดเรียงพารามิเตอร์ใหม่เพื่อให้วางการดำเนินการไว้นอกวงเล็บได้

ฟังก์ชันระดับบนสุด

แพ็กเกจ bundleOf(vararg pairs: Pair<String, Any?>)

แสดงผล Bundle ใหม่ที่มีคู่คีย์/ค่าที่ระบุเป็นองค์ประกอบ

PersistableBundle persistableBundleOf(vararg pairs: Pair<String, Any?>)

แสดงผล PersistableBundle ใหม่ที่มีคู่คีย์/ค่าที่ระบุเป็นองค์ประกอบ

T trace(sectionName: String, block: () -> T)

ห่อหุ้มบล็อกที่ระบุในการเรียกใช้ Trace.beginSection (พร้อม sectionName ที่ระบุ) และ Trace.endSection

androidx.core.text

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.text.Spannable
หน่วย Spannable.clearSpans()

ล้างช่วงทั้งหมดจากข้อความนี้

โอเปอเรเตอร์ Unit Spannable.set(start: Int, end: Int, span: Any)

เพิ่ม span ไปยังช่วงstart&hellip;end ของข้อความ

โอเปอเรเตอร์ Unit Spannable.set(range: IntRange, span: Any)

เพิ่ม span ลงใน range ของข้อความ

สำหรับ android.text.SpannableStringBuilder
SpannableStringBuilder SpannableStringBuilder.backgroundColor(color: Int, builderAction: SpannableStringBuilder.() -> Unit)

ตัดข้อความที่ต่อท้ายใน builderAction ใน BackgroundColorSpan

SpannableStringBuilder SpannableStringBuilder.bold(builderAction: SpannableStringBuilder.() -> Unit)

ตัดข้อความที่ต่อท้ายใน builderAction ใน StyleSpan แบบตัวหนา

SpannableStringBuilder SpannableStringBuilder.color(color: Int, builderAction: SpannableStringBuilder.() -> Unit)

ตัดข้อความที่ต่อท้ายใน builderAction ใน ForegroundColorSpan

SpannableStringBuilder SpannableStringBuilder.inSpans(vararg spans: Any, builderAction: SpannableStringBuilder.() -> Unit)

ตัดข้อความที่ต่อท้ายใน builderAction ใน spans

SpannableStringBuilder SpannableStringBuilder.inSpans(span: Any, builderAction: SpannableStringBuilder.() -> Unit)

ตัดข้อความที่ต่อท้ายใน builderAction ใน span

SpannableStringBuilder SpannableStringBuilder.italic(builderAction: SpannableStringBuilder.() -> Unit)

ตัดข้อความที่ต่อท้ายใน builderAction ใน StyleSpan แบบตัวเอียง

SpannableStringBuilder SpannableStringBuilder.scale(proportion: Float, builderAction: SpannableStringBuilder.() -> Unit)

ตัดข้อความที่ต่อท้ายใน builderAction ใน RelativeSizeSpan

SpannableStringBuilder SpannableStringBuilder.strikeThrough(builderAction: SpannableStringBuilder.() -> Unit)

ตัดข้อความที่ต่อท้ายใน builderAction ใน StrikethroughSpan

SpannableStringBuilder SpannableStringBuilder.subscript(builderAction: SpannableStringBuilder.() -> Unit)

ตัดข้อความที่ต่อท้ายใน builderAction ใน SubscriptSpan

SpannableStringBuilder SpannableStringBuilder.superscript(builderAction: SpannableStringBuilder.() -> Unit)

ตัดข้อความที่ต่อท้ายใน builderAction ใน SuperscriptSpan

SpannableStringBuilder SpannableStringBuilder.underline(builderAction: SpannableStringBuilder.() -> Unit)

ตัดข้อความที่ต่อท้ายใน builderAction ใน UnderlineSpan

สำหรับ android.text.Spanned
อาร์เรย์<out T> Spanned.getSpans(start: Int = 0, end: Int = length)

รับช่วงทั้งหมดที่เป็นอินสแตนซ์ของ T

สตริง Spanned.toHtml(option: Int = TO_HTML_PARAGRAPH_LINES_CONSECUTIVE)

แสดงผลสตริง HTML จากช่วงใน Spanned นี้

สำหรับ kotlin.CharSequence
บูลีน CharSequence.isDigitsOnly()

แสดงผลว่า CharSequence ที่ระบุมีเฉพาะตัวเลขหรือไม่

Spannable CharSequence.toSpannable()

แสดงผล Spannable ใหม่จาก CharSequence หรือแหล่งที่มาเองหากเป็นอินสแตนซ์ของ SpannableString อยู่แล้ว

ขยาย CharSequence.toSpanned()

แสดงผล Spanned ใหม่จาก CharSequence หรือแหล่งที่มาเองหากเป็นอินสแตนซ์ของ SpannedString อยู่แล้ว

Int CharSequence.trimmedLength()

แสดงความยาวที่ CharSequence ที่ระบุจะมี หากมีการตัดช่องว่างและอักขระควบคุม ASCII ออกจากจุดเริ่มต้นและจุดสิ้นสุด เช่นเดียวกับ String.trim

สำหรับ kotlin.String
สตริง String.htmlEncode()

เข้ารหัสสตริงด้วย HTML

ขยาย String.parseAsHtml(flags: Int = FROM_HTML_MODE_LEGACY, imageGetter: ImageGetter? = null, tagHandler: TagHandler? = null)

แสดงผล Spanned จากการแยกวิเคราะห์สตริงนี้เป็น HTML

คุณสมบัติของส่วนขยาย

สำหรับ java.util.Locale
Int Locale.layoutDirection()

แสดงผลทิศทางการจัดวางสำหรับภาษาที่ระบุ

ฟังก์ชันระดับบนสุด

SpannedString buildSpannedString(builderAction: SpannableStringBuilder.() -> Unit)

สร้างสตริงใหม่โดยการป้อนข้อมูลลงใน SpannableStringBuilder ที่สร้างขึ้นใหม่โดยใช้ builderAction ที่ระบุ แล้วแปลงเป็น SpannedString

androidx.core.transition

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.transition.Transition
TransitionListener Transition.addListener(crossinline onEnd: (transition: Transition) -> Unit = {}, crossinline onStart: (transition: Transition) -> Unit = {}, crossinline onCancel: (transition: Transition) -> Unit = {}, crossinline onResume: (transition: Transition) -> Unit = {}, crossinline onPause: (transition: Transition) -> Unit = {})

เพิ่ม Listener ไปยังการเปลี่ยนฉากนี้โดยใช้การดำเนินการที่ระบุ

TransitionListener Transition.doOnCancel(crossinline action: (transition: Transition) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้เมื่อมีการยกเลิกการเปลี่ยนฉากนี้

TransitionListener Transition.doOnEnd(crossinline action: (transition: Transition) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้เมื่อการเปลี่ยนผ่านนี้สิ้นสุดลง

TransitionListener Transition.doOnPause(crossinline action: (transition: Transition) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้เมื่อหยุดการเปลี่ยนฉากนี้ชั่วคราว

TransitionListener Transition.doOnResume(crossinline action: (transition: Transition) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้เมื่อการเปลี่ยนฉากนี้กลับมาทำงานต่อหลังจากหยุดชั่วคราว

TransitionListener Transition.doOnStart(crossinline action: (transition: Transition) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้เมื่อการเปลี่ยนฉากนี้เริ่มต้นขึ้น

androidx.core.util

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.util.AtomicFile
ByteArray AtomicFile.readBytes()

รับเนื้อหาทั้งหมดของไฟล์นี้เป็นอาร์เรย์ไบต์

สตริง AtomicFile.readText(charset: Charset = Charsets.UTF_8)

รับเนื้อหาทั้งหมดของไฟล์นี้เป็นสตริงโดยใช้ UTF-8 หรือ charset ที่ระบุ

หน่วย AtomicFile.tryWrite(block: (out: FileOutputStream) -> Unit)

ดำเนินการเขียนภายใน block ในไฟล์นี้

หน่วย AtomicFile.writeBytes(array: ByteArray)

ตั้งค่าเนื้อหาของไฟล์นี้เป็นอาร์เรย์ของไบต์

หน่วย AtomicFile.writeText(text: String, charset: Charset = Charsets.UTF_8)

ตั้งค่าเนื้อหาของไฟล์นี้เป็นข้อความที่เข้ารหัสโดยใช้ UTF-8 หรือชุดอักขระที่ระบุ

สำหรับ android.util.LongSparseArray
ตัวดำเนินการ บูลีน LongSparseArray<T>.contains(key: Long)

แสดงค่าจริงหากคอลเล็กชันมี key

บูลีน LongSparseArray<T>.containsKey(key: Long)

แสดงค่าจริงหากคอลเล็กชันมี key

บูลีน LongSparseArray<T>.containsValue(value: T)

แสดงค่าจริงหากคอลเล็กชันมี value

หน่วย LongSparseArray<T>.forEach(action: (key: Long, value: T) -> Unit)

ดำเนินการการดำเนินการที่ระบุสำหรับรายการคีย์/ค่าแต่ละรายการ

T LongSparseArray<T>.getOrDefault(key: Long, defaultValue: T)

แสดงผลค่าที่สอดคล้องกับ key หรือ defaultValue เมื่อไม่มี

T LongSparseArray<T>.getOrElse(key: Long, defaultValue: () -> T)

แสดงค่าที่สอดคล้องกับ key หรือจาก defaultValue เมื่อไม่มี

บูลีน LongSparseArray<T>.isEmpty()

แสดงค่าจริงเมื่อคอลเล็กชันไม่มีองค์ประกอบ

บูลีน LongSparseArray<T>.isNotEmpty()

แสดงค่าเป็นจริงเมื่อคอลเล็กชันมีองค์ประกอบ

LongIterator LongSparseArray<T>.keyIterator()

ส่งคืนตัววนซ้ำเหนือคีย์ของคอลเล็กชัน

operator LongSparseArray<T> LongSparseArray<T>.plus(other: LongSparseArray<T>)

สร้างคอลเล็กชันใหม่โดยการเพิ่มหรือแทนที่รายการจากอื่นๆ

หน่วย LongSparseArray<T>.putAll(other: LongSparseArray<T>)

อัปเดตคอลเล็กชันนี้โดยการเพิ่มหรือแทนที่รายการจากที่อื่น

บูลีน LongSparseArray<T>.remove(key: Long, value: T)

นำรายการสำหรับ key ออกก็ต่อเมื่อมีการแมปกับ value

โอเปอเรเตอร์ Unit LongSparseArray<T>.set(key: Long, value: T)

อนุญาตให้ใช้โอเปอเรเตอร์ดัชนีเพื่อจัดเก็บค่าในคอลเล็กชัน

Iterator<T> LongSparseArray<T>.valueIterator()

แสดงผลตัววนซ้ำเหนือค่าของคอลเล็กชัน

สำหรับ android.util.Pair
operator F Pair<F, S>.component1()

แสดงผลคอมโพเนนต์แรกของคู่

โอเปอเรเตอร์ S Pair<F, S>.component2()

แสดงผลคอมโพเนนต์ที่ 2 ของคู่

Pair< F, S> Pair<F, S>.toKotlinPair()

แสดงผล Pair นี้เป็น kotlin.Pair

สำหรับ android.util.Range
infix Range<T> Range<T>.and(other: Range<T>)

แสดงผลอินเตอร์เซกชันของช่วงนี้และother

ตัวดำเนินการ ช่วง<T> Range<T>.plus(value: T)

แสดงผลช่วงที่เล็กที่สุดซึ่งรวมค่านี้และ value

ตัวดำเนินการ ช่วง<T> Range<T>.plus(other: Range<T>)

แสดงช่วงที่เล็กที่สุดซึ่งรวมถึงรายการนี้และรายการอื่นๆ

ClosedRange<T> Range<T>.toClosedRange()

แสดงผล Range นี้เป็น ClosedRange

สำหรับ android.util.Size
operator Int Size.component1()

แสดงผล "width" ซึ่งเป็นคอมโพเนนต์แรกของ Size นี้

operator Int Size.component2()

แสดงผล "height" ซึ่งเป็นคอมโพเนนต์ที่ 2 ของ Size นี้

สำหรับ android.util.SizeF
โอเปอเรเตอร์ Float SizeF.component1()

แสดงผล "width" ซึ่งเป็นคอมโพเนนต์แรกของ SizeF นี้

โอเปอเรเตอร์ Float SizeF.component2()

แสดงผล "height" ซึ่งเป็นคอมโพเนนต์ที่ 2 ของ SizeF นี้

สำหรับ android.util.SparseArray
ตัวดำเนินการ บูลีน SparseArray<T>.contains(key: Int)

แสดงค่าจริงหากคอลเล็กชันมี key

บูลีน SparseArray<T>.containsKey(key: Int)

แสดงค่าจริงหากคอลเล็กชันมี key

บูลีน SparseArray<T>.containsValue(value: T)

แสดงค่าจริงหากคอลเล็กชันมี value

หน่วย SparseArray<T>.forEach(action: (key: Int, value: T) -> Unit)

ดำเนินการการดำเนินการที่ระบุสำหรับรายการคีย์/ค่าแต่ละรายการ

T SparseArray<T>.getOrDefault(key: Int, defaultValue: T)

แสดงผลค่าที่สอดคล้องกับ key หรือ defaultValue เมื่อไม่มี

T SparseArray<T>.getOrElse(key: Int, defaultValue: () -> T)

แสดงค่าที่สอดคล้องกับ key หรือจาก defaultValue เมื่อไม่มี

บูลีน SparseArray<T>.isEmpty()

แสดงค่าจริงเมื่อคอลเล็กชันไม่มีองค์ประกอบ

บูลีน SparseArray<T>.isNotEmpty()

แสดงค่าเป็นจริงเมื่อคอลเล็กชันมีองค์ประกอบ

IntIterator SparseArray<T>.keyIterator()

ส่งคืนตัววนซ้ำเหนือคีย์ของคอลเล็กชัน

operator SparseArray<T> SparseArray<T>.plus(other: SparseArray<T>)

สร้างคอลเล็กชันใหม่โดยการเพิ่มหรือแทนที่รายการจากอื่นๆ

หน่วย SparseArray<T>.putAll(other: SparseArray<T>)

อัปเดตคอลเล็กชันนี้โดยการเพิ่มหรือแทนที่รายการจากที่อื่น

บูลีน SparseArray<T>.remove(key: Int, value: T)

นำรายการสำหรับ key ออกก็ต่อเมื่อมีการแมปกับ value

โอเปอเรเตอร์ Unit SparseArray<T>.set(key: Int, value: T)

อนุญาตให้ใช้โอเปอเรเตอร์ดัชนีเพื่อจัดเก็บค่าในคอลเล็กชัน

Iterator<T> SparseArray<T>.valueIterator()

แสดงผลตัววนซ้ำเหนือค่าของคอลเล็กชัน

สำหรับ android.util.SparseBooleanArray
ตัวดำเนินการ บูลีน SparseBooleanArray.contains(key: Int)

แสดงค่าจริงหากคอลเล็กชันมี key

บูลีน SparseBooleanArray.containsKey(key: Int)

แสดงค่าจริงหากคอลเล็กชันมี key

บูลีน SparseBooleanArray.containsValue(value: Boolean)

แสดงค่าจริงหากคอลเล็กชันมี value

หน่วย SparseBooleanArray.forEach(action: (key: Int, value: Boolean) -> Unit)

ดำเนินการการดำเนินการที่ระบุสำหรับรายการคีย์/ค่าแต่ละรายการ

บูลีน SparseBooleanArray.getOrDefault(key: Int, defaultValue: Boolean)

แสดงผลค่าที่สอดคล้องกับ key หรือ defaultValue เมื่อไม่มี

บูลีน SparseBooleanArray.getOrElse(key: Int, defaultValue: () -> Boolean)

แสดงค่าที่สอดคล้องกับ key หรือจาก defaultValue เมื่อไม่มี

บูลีน SparseBooleanArray.isEmpty()

แสดงค่าจริงเมื่อคอลเล็กชันไม่มีองค์ประกอบ

บูลีน SparseBooleanArray.isNotEmpty()

แสดงค่าเป็นจริงเมื่อคอลเล็กชันมีองค์ประกอบ

IntIterator SparseBooleanArray.keyIterator()

ส่งคืนตัววนซ้ำเหนือคีย์ของคอลเล็กชัน

operator SparseBooleanArray SparseBooleanArray.plus(other: SparseBooleanArray)

สร้างคอลเล็กชันใหม่โดยการเพิ่มหรือแทนที่รายการจากอื่นๆ

หน่วย SparseBooleanArray.putAll(other: SparseBooleanArray)

อัปเดตคอลเล็กชันนี้โดยการเพิ่มหรือแทนที่รายการจากที่อื่น

บูลีน SparseBooleanArray.remove(key: Int, value: Boolean)

นำรายการสำหรับ key ออกก็ต่อเมื่อมีการแมปกับ value

โอเปอเรเตอร์ Unit SparseBooleanArray.set(key: Int, value: Boolean)

อนุญาตให้ใช้โอเปอเรเตอร์ดัชนีเพื่อจัดเก็บค่าในคอลเล็กชัน

BooleanIterator SparseBooleanArray.valueIterator()

แสดงผลตัววนซ้ำเหนือค่าของคอลเล็กชัน

สำหรับ android.util.SparseIntArray
ตัวดำเนินการ บูลีน SparseIntArray.contains(key: Int)

แสดงค่าจริงหากคอลเล็กชันมี key

บูลีน SparseIntArray.containsKey(key: Int)

แสดงค่าจริงหากคอลเล็กชันมี key

บูลีน SparseIntArray.containsValue(value: Int)

แสดงค่าจริงหากคอลเล็กชันมี value

หน่วย SparseIntArray.forEach(action: (key: Int, value: Int) -> Unit)

ดำเนินการการดำเนินการที่ระบุสำหรับรายการคีย์/ค่าแต่ละรายการ

Int SparseIntArray.getOrDefault(key: Int, defaultValue: Int)

แสดงผลค่าที่สอดคล้องกับ key หรือ defaultValue เมื่อไม่มี

Int SparseIntArray.getOrElse(key: Int, defaultValue: () -> Int)

แสดงค่าที่สอดคล้องกับ key หรือจาก defaultValue เมื่อไม่มี

บูลีน SparseIntArray.isEmpty()

แสดงค่าจริงเมื่อคอลเล็กชันไม่มีองค์ประกอบ

บูลีน SparseIntArray.isNotEmpty()

แสดงค่าเป็นจริงเมื่อคอลเล็กชันมีองค์ประกอบ

IntIterator SparseIntArray.keyIterator()

ส่งคืนตัววนซ้ำเหนือคีย์ของคอลเล็กชัน

operator SparseIntArray SparseIntArray.plus(other: SparseIntArray)

สร้างคอลเล็กชันใหม่โดยการเพิ่มหรือแทนที่รายการจากอื่นๆ

หน่วย SparseIntArray.putAll(other: SparseIntArray)

อัปเดตคอลเล็กชันนี้โดยการเพิ่มหรือแทนที่รายการจากที่อื่น

บูลีน SparseIntArray.remove(key: Int, value: Int)

นำรายการสำหรับ key ออกก็ต่อเมื่อมีการแมปกับ value

โอเปอเรเตอร์ Unit SparseIntArray.set(key: Int, value: Int)

อนุญาตให้ใช้โอเปอเรเตอร์ดัชนีเพื่อจัดเก็บค่าในคอลเล็กชัน

IntIterator SparseIntArray.valueIterator()

แสดงผลตัววนซ้ำเหนือค่าของคอลเล็กชัน

สำหรับ android.util.SparseLongArray
ตัวดำเนินการ บูลีน SparseLongArray.contains(key: Int)

แสดงค่าจริงหากคอลเล็กชันมี key

บูลีน SparseLongArray.containsKey(key: Int)

แสดงค่าจริงหากคอลเล็กชันมี key

บูลีน SparseLongArray.containsValue(value: Long)

แสดงค่าจริงหากคอลเล็กชันมี value

หน่วย SparseLongArray.forEach(action: (key: Int, value: Long) -> Unit)

ดำเนินการการดำเนินการที่ระบุสำหรับรายการคีย์/ค่าแต่ละรายการ

ยาว SparseLongArray.getOrDefault(key: Int, defaultValue: Long)

แสดงผลค่าที่สอดคล้องกับ key หรือ defaultValue เมื่อไม่มี

ยาว SparseLongArray.getOrElse(key: Int, defaultValue: () -> Long)

แสดงค่าที่สอดคล้องกับ key หรือจาก defaultValue เมื่อไม่มี

บูลีน SparseLongArray.isEmpty()

แสดงค่าจริงเมื่อคอลเล็กชันไม่มีองค์ประกอบ

บูลีน SparseLongArray.isNotEmpty()

แสดงค่าเป็นจริงเมื่อคอลเล็กชันมีองค์ประกอบ

IntIterator SparseLongArray.keyIterator()

ส่งคืนตัววนซ้ำเหนือคีย์ของคอลเล็กชัน

operator SparseLongArray SparseLongArray.plus(other: SparseLongArray)

สร้างคอลเล็กชันใหม่โดยการเพิ่มหรือแทนที่รายการจากอื่นๆ

หน่วย SparseLongArray.putAll(other: SparseLongArray)

อัปเดตคอลเล็กชันนี้โดยการเพิ่มหรือแทนที่รายการจากที่อื่น

บูลีน SparseLongArray.remove(key: Int, value: Long)

นำรายการสำหรับ key ออกก็ต่อเมื่อตั้งค่าเป็น value

โอเปอเรเตอร์ Unit SparseLongArray.set(key: Int, value: Long)

อนุญาตให้ใช้โอเปอเรเตอร์ดัชนีเพื่อจัดเก็บค่าในคอลเล็กชัน

LongIterator SparseLongArray.valueIterator()

แสดงผลตัววนซ้ำเหนือค่าของคอลเล็กชัน

สำหรับ kotlin.Double
ครึ่ง Double.toHalf()

แสดงผลอินสแตนซ์ Half ที่แสดง Double ที่ระบุ

สำหรับ kotlin.Float
ครึ่ง Float.toHalf()

แสดงผลอินสแตนซ์ Half ที่แสดง Float ที่ระบุ

สำหรับ kotlin.Pair
Pair< F, S> Pair<F, S>.toAndroidPair()

แสดงผล kotlin.Pair นี้เป็น Pair ของ Android

สำหรับ kotlin.Short
ครึ่ง Short.toHalf()

แสดงผลอินสแตนซ์ Half ที่แสดง Short ที่ระบุ

สำหรับ kotlin.String
ครึ่ง String.toHalf()

แสดงผลอินสแตนซ์ Half ที่แสดง String ที่ระบุ

สำหรับ kotlin.ranges.ClosedRange
ช่วง<T> ClosedRange<T>.toRange()

แสดงผล ClosedRange นี้เป็น Range

คุณสมบัติของส่วนขยาย

สำหรับ android.util.LongSparseArray
Int LongSparseArray<T>.size()

แสดงผลจำนวนคู่คีย์/ค่าในคอลเล็กชัน

สำหรับ android.util.SparseArray
Int SparseArray<T>.size()

แสดงผลจำนวนคู่คีย์/ค่าในคอลเล็กชัน

สำหรับ android.util.SparseBooleanArray
Int SparseBooleanArray.size()

แสดงผลจำนวนคู่คีย์/ค่าในคอลเล็กชัน

สำหรับ android.util.SparseIntArray
Int SparseIntArray.size()

แสดงผลจำนวนคู่คีย์/ค่าในคอลเล็กชัน

สำหรับ android.util.SparseLongArray
Int SparseLongArray.size()

แสดงผลจำนวนรายการคู่คีย์/ค่าในคอลเล็กชัน

ฟังก์ชันระดับบนสุด

LruCache< K, V> lruCache(maxSize: Int, crossinline sizeOf: (key: K, value: V) -> Int = { _, _ -> 1 }, crossinline create: (key: K) -> V? = { null as V? }, crossinline onEntryRemoved: (evicted: Boolean, key: K, oldValue: V, newValue: V?) -> Unit = { _, _, _, _ -> })

สร้าง LruCache ด้วยพารามิเตอร์ที่ระบุ

infix Range<T> T.rangeTo(that: T)

สร้างช่วงจากค่า Comparable นี้ไปยัง ค่าดังกล่าว

androidx.core.view

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.view.Menu
ตัวดำเนินการ บูลีน Menu.contains(item: MenuItem)

แสดงผล true หากพบ item ในเมนูนี้

หน่วย Menu.forEach(action: (item: MenuItem) -> Unit)

ดำเนินการที่ระบุกับแต่ละรายการในเมนูนี้

หน่วย Menu.forEachIndexed(action: (index: Int, item: MenuItem) -> Unit)

ดำเนินการที่ระบุในแต่ละรายการในเมนูนี้ โดยระบุดัชนีตามลำดับ

operator MenuItem Menu.get(index: Int)

แสดงเมนูที่ดัชนี

บูลีน Menu.isEmpty()

แสดงค่าจริงหากเมนูนี้ไม่มีรายการ

บูลีน Menu.isNotEmpty()

แสดงค่าเป็นจริงหากเมนูนี้มีรายการอย่างน้อย 1 รายการ

operator MutableIterator<MenuItem> Menu.iterator()

แสดงผล MutableIterator สำหรับรายการในเมนูนี้

โอเปอเรเตอร์ Unit Menu.minusAssign(item: MenuItem)

นำรายการออกจากเมนูนี้

สำหรับ android.view.View
หน่วย View.doOnAttach(crossinline action: (view: View) -> Unit)

ดำเนินการที่ระบุเมื่อแนบมุมมองนี้กับหน้าต่าง

หน่วย View.doOnDetach(crossinline action: (view: View) -> Unit)

ดำเนินการที่ระบุเมื่อมุมมองนี้แยกออกจากหน้าต่าง

หน่วย View.doOnLayout(crossinline action: (view: View) -> Unit)

ดำเนินการที่ระบุเมื่อวางเลย์เอาต์มุมมองนี้

หน่วย View.doOnNextLayout(crossinline action: (view: View) -> Unit)

ดำเนินการที่ระบุเมื่อมีการวางเลย์เอาต์มุมมองนี้ในครั้งถัดไป

OneShotPreDrawListener View.doOnPreDraw(crossinline action: (view: View) -> Unit)

ดำเนินการที่ระบุเมื่อกำลังจะวาดแผนผังมุมมอง

บิตแมป View.drawToBitmap(config: Config = Bitmap.Config.ARGB_8888)

แสดงการแทนค่า Bitmap ของ View นี้

Runnable View.postDelayed(delayInMillis: Long, crossinline action: () -> Unit)

เวอร์ชันของ View.postDelayed ซึ่งจัดเรียงพารามิเตอร์ใหม่เพื่อให้วางการดำเนินการ ไว้นอกวงเล็บได้

Runnable View.postOnAnimationDelayed(delayInMillis: Long, crossinline action: () -> Unit)

เวอร์ชันของ View.postOnAnimationDelayed ซึ่งเรียงลำดับพารามิเตอร์ใหม่เพื่อให้วางการดำเนินการ ไว้นอกวงเล็บได้

หน่วย View.setPadding(@Px size: Int)

ตั้งค่าระยะขอบของมุมมอง

หน่วย View.updateLayoutParams(block: LayoutParams.() -> Unit)

เรียกใช้ block ด้วย layoutParams ของ View และกำหนด layoutParams ใหม่ด้วย เวอร์ชันที่อัปเดตแล้ว

หน่วย View.updateLayoutParams(block: T.() -> Unit)

เรียกใช้ block ด้วย layoutParams ของ View เวอร์ชันที่พิมพ์แล้ว และกำหนด layoutParams ใหม่ด้วยเวอร์ชันที่อัปเดต

หน่วย View.updatePadding(@Px left: Int = paddingLeft, @Px top: Int = paddingTop, @Px right: Int = paddingRight, @Px bottom: Int = paddingBottom)

อัปเดตระยะขอบของมุมมองนี้

หน่วย View.updatePaddingRelative(@Px start: Int = paddingStart, @Px top: Int = paddingTop, @Px end: Int = paddingEnd, @Px bottom: Int = paddingBottom)

อัปเดตระยะห่างภายในที่สัมพันธ์กันของมุมมองนี้

สำหรับ android.view.ViewGroup
ตัวดำเนินการ บูลีน ViewGroup.contains(view: View)

แสดงผล true หากพบ view ในกลุ่มมุมมองนี้

หน่วย ViewGroup.forEach(action: (view: View) -> Unit)

ดำเนินการที่ระบุในแต่ละมุมมองในกลุ่มมุมมองนี้

หน่วย ViewGroup.forEachIndexed(action: (index: Int, view: View) -> Unit)

ดำเนินการที่ระบุในแต่ละมุมมองในกลุ่มมุมมองนี้ โดยระบุดัชนีตามลำดับ

ผู้ปฏิบัติงาน ดู ViewGroup.get(index: Int)

แสดงผลมุมมองที่ดัชนี

บูลีน ViewGroup.isEmpty()

แสดงค่าจริงหากกลุ่มมุมมองนี้ไม่มีมุมมอง

บูลีน ViewGroup.isNotEmpty()

แสดงค่าเป็นจริงหากกลุ่มข้อมูลพร็อพเพอร์ตี้นี้มีข้อมูลพร็อพเพอร์ตี้อย่างน้อย 1 รายการ

operator MutableIterator<View> ViewGroup.iterator()

แสดงผล MutableIterator เหนือมุมมองในกลุ่มมุมมองนี้

โอเปอเรเตอร์ Unit ViewGroup.minusAssign(view: View)

นำมุมมองออกจากกลุ่มมุมมองนี้

โอเปอเรเตอร์ Unit ViewGroup.plusAssign(view: View)

เพิ่มมุมมองไปยังกลุ่มมุมมองนี้

สำหรับ android.view.ViewGroup.MarginLayoutParams
หน่วย MarginLayoutParams.setMargins(@Px size: Int)

กำหนดระยะขอบใน MarginLayoutParams ของ ViewGroup

หน่วย MarginLayoutParams.updateMargins(@Px left: Int = leftMargin, @Px top: Int = topMargin, @Px right: Int = rightMargin, @Px bottom: Int = bottomMargin)

อัปเดตขอบใน ViewGroup ของ ViewGroup.MarginLayoutParams

หน่วย MarginLayoutParams.updateMarginsRelative(@Px start: Int = marginStart, @Px top: Int = topMargin, @Px end: Int = marginEnd, @Px bottom: Int = bottomMargin)

อัปเดตระยะขอบที่สัมพันธ์กันใน MarginLayoutParams ของ ViewGroup

คุณสมบัติของส่วนขยาย

สำหรับ android.view.Menu
Sequence<MenuItem> Menu.children()

แสดงผล Sequence ของรายการในเมนูนี้

Int Menu.size()

แสดงผลจำนวนรายการในเมนูนี้

สำหรับ android.view.View
บูลีน View.isGone()

แสดงผลเป็นจริงเมื่อระดับการมองเห็นของมุมมองนี้เป็น View.GONE หากไม่ แสดงผลเป็นเท็จ

บูลีน View.isInvisible()

แสดงผลเป็นจริงเมื่อการมองเห็นของมุมมองนี้เป็น View.INVISIBLE หากไม่ แสดงผลเป็นเท็จ

บูลีน View.isVisible()

แสดงผลเป็นจริงเมื่อระดับการมองเห็นของมุมมองนี้คือ View.VISIBLE หากไม่เป็นเช่นนั้นจะแสดงผลเป็นเท็จ

Int View.marginBottom()

แสดงผลระยะขอบด้านล่างหาก LayoutParams ของมุมมองนี้เป็น ViewGroup.MarginLayoutParams มิฉะนั้นจะแสดงผล 0

Int View.marginEnd()

แสดงผลขอบด้านท้ายหาก LayoutParams ของมุมมองนี้เป็น ViewGroup.MarginLayoutParams มิฉะนั้นจะแสดงผล 0

Int View.marginLeft()

แสดงผลระยะขอบด้านซ้ายหาก LayoutParams ของมุมมองนี้เป็น ViewGroup.MarginLayoutParams มิฉะนั้นจะเป็น 0

Int View.marginRight()

แสดงผลขอบขวาหาก LayoutParams ของมุมมองนี้เป็น ViewGroup.MarginLayoutParams หรือ 0

Int View.marginStart()

แสดงผลระยะขอบเริ่มต้นหาก LayoutParams ของมุมมองนี้เป็น ViewGroup.MarginLayoutParams มิฉะนั้นจะแสดงผล 0

Int View.marginTop()

แสดงผลขอบด้านบนหาก LayoutParams ของมุมมองนี้เป็น ViewGroup.MarginLayoutParams มิฉะนั้นจะแสดงผล 0

สำหรับ android.view.ViewGroup
ลำดับ<ดู> ViewGroup.children()

แสดงผล Sequence ของ View ระดับล่างในกลุ่ม View นี้

Int ViewGroup.size()

แสดงผลจำนวนการดูในกลุ่มมุมมองนี้

androidx.core.widget

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.16.0"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.16.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.widget.TextView
TextWatcher TextView.addTextChangedListener(crossinline beforeTextChanged: (text: CharSequence?, start: Int, count: Int, after: Int) -> Unit = { _, _, _, _ -> }, crossinline onTextChanged: (text: CharSequence?, start: Int, count: Int, after: Int) -> Unit = { _, _, _, _ -> }, crossinline afterTextChanged: (text: Editable?) -> Unit = {})

เพิ่ม Listener การเปลี่ยนแปลงข้อความไปยัง TextView นี้โดยใช้การดำเนินการที่ระบุ

TextWatcher TextView.doAfterTextChanged(crossinline action: (text: Editable?) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้หลังจากข้อความมีการเปลี่ยนแปลง

TextWatcher TextView.doBeforeTextChanged(crossinline action: (text: CharSequence?, start: Int, count: Int, after: Int) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้ก่อนที่จะมีการเปลี่ยนแปลงข้อความ

TextWatcher TextView.doOnTextChanged(crossinline action: (text: CharSequence?, start: Int, count: Int, after: Int) -> Unit)

เพิ่มการดำเนินการที่จะเรียกใช้เมื่อข้อความมีการเปลี่ยนแปลง

androidx.dynamicanimation.animation

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.dynamicanimation:dynamicanimation-ktx:"
}

Kotlin

dependencies {
    implementation("androidx.dynamicanimation:dynamicanimation-ktx:")
}

ฟังก์ชันของส่วนขยาย

สำหรับ SpringAnimation
SpringAnimation SpringAnimation.withSpringForceProperties(func: SpringForce.() -> Unit)

อัปเดตหรือใช้พร็อพเพอร์ตี้แรงสปริง เช่น SpringForce.mDampingRatio, SpringForce.mFinalPosition และความแข็งบน SpringAnimation

ฟังก์ชันระดับบนสุด

FlingAnimation flingAnimationOf(setter: (Float) -> Unit, getter: () -> Float)

สร้าง FlingAnimation สำหรับพร็อพเพอร์ตี้ที่เข้าถึงได้ผ่านตัวตั้งค่าและตัวรับค่าที่ระบุ

SpringAnimation springAnimationOf(setter: (Float) -> Unit, getter: () -> Float, finalPosition: Float = Float.NaN)

สร้าง SpringAnimation สำหรับพร็อพเพอร์ตี้ที่เข้าถึงได้ผ่าน Setter และ Getter ที่ระบุ

androidx.fragment.app

การขึ้นต่อกัน

ดึงดูด

dependencies {
    implementation "androidx.fragment:fragment-ktx:1.8.8"
}

Kotlin

dependencies {
    implementation("androidx.fragment:fragment-ktx:1.8.8")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.view.View
F View.findFragment()

ค้นหา Fragment ที่เชื่อมโยงกับ View

สำหรับ Fragment
Lazy<VM> Fragment.activityViewModels(noinline factoryProducer: () -> ViewModelProvider.Factory = null)

แสดงผลตัวแทนพร็อพเพอร์ตี้เพื่อเข้าถึง ViewModel ของกิจกรรมหลัก หากระบุ factoryProducer ระบบจะใช้ ViewModelProvider.Factory ที่แสดงผลโดย factoryProducer เพื่อสร้าง ViewModel เป็นครั้งแรก

Lazy<VM> Fragment.createViewModelLazy(viewModelClass: KClass<VM>, storeProducer: () -> ViewModelStore, factoryProducer: () -> ViewModelProvider.Factory = null)

เมธอดตัวช่วยสำหรับการสร้าง ViewModelLazy ซึ่งจะแก้ปัญหา null ที่ส่งเป็น factoryProducer ไปยังโรงงานเริ่มต้น

Lazy<VM> Fragment.viewModels(noinline ownerProducer: () -> ViewModelStoreOwner = { this }, noinline factoryProducer: () -> ViewModelProvider.Factory = null)

ส่งคืนตัวแทนพร็อพเพอร์ตี้เพื่อเข้าถึง ViewModel โดยมีขอบเขตเป็น default ที่กำหนดไว้สำหรับ Fragment นี้

สำหรับ FragmentTransaction
FragmentTransaction FragmentTransaction.add(@IdRes containerViewId: Int, tag: String? = null, args: Bundle? = null)

เพิ่ม Fragment ลงใน FragmentManager ที่เชื่อมโยง โดยขยาย มุมมองของ Fragment ลงในมุมมองคอนเทนเนอร์ที่ระบุโดย containerViewId เพื่อเรียกข้อมูลในภายหลังผ่าน FragmentManager.findFragmentById

FragmentTransaction FragmentTransaction.add(tag: String, args: Bundle? = null)

เพิ่ม Fragment ไปยัง FragmentManager ที่เชื่อมโยงโดยไม่ เพิ่ม Fragment ไปยัง Container View ใดๆ

FragmentTransaction FragmentTransaction.replace(@IdRes containerViewId: Int, tag: String? = null, args: Bundle? = null)

แทนที่ข้อมูลโค้ดที่มีอยู่ซึ่งเพิ่มลงในคอนเทนเนอร์

สำหรับ FragmentManager
หน่วย FragmentManager.commit(allowStateLoss: Boolean = false, body: FragmentTransaction.() -> Unit)

เรียกใช้ body ใน FragmentTransaction ซึ่งจะคอมมิตโดยอัตโนมัติหากดำเนินการเสร็จสมบูรณ์โดยไม่มีข้อยกเว้น

หน่วย FragmentManager.commitNow(allowStateLoss: Boolean = false, body: FragmentTransaction.() -> Unit)

เรียกใช้ body ใน FragmentTransaction ซึ่งจะคอมมิตโดยอัตโนมัติหากดำเนินการเสร็จสมบูรณ์โดยไม่มีข้อยกเว้น

หน่วย FragmentManager.transaction(now: Boolean = false, allowStateLoss: Boolean = false, body: FragmentTransaction.() -> Unit)

เรียกใช้ body ใน FragmentTransaction ซึ่งจะคอมมิตโดยอัตโนมัติหากดำเนินการเสร็จสมบูรณ์โดยไม่มีข้อยกเว้น

androidx.fragment.app.testing

การขึ้นต่อกัน

ดึงดูด

dependencies {
    implementation "androidx.fragment:fragment-testing:1.8.8"
}

Kotlin

dependencies {
    implementation("androidx.fragment:fragment-testing:1.8.8")
}

ฟังก์ชันระดับบนสุด

FragmentScenario<F!> launchFragment(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, factory: FragmentFactory? = null)

เปิดใช้ Fragment ที่มีอาร์กิวเมนต์ที่ระบุซึ่งโฮสต์โดย FragmentActivity ว่างโดยใช้ FragmentFactory ที่ระบุ และรอให้ Fragment ดังกล่าวเข้าสู่สถานะ "กลับมาทำงานต่อ"

FragmentScenario<F!> launchFragment(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, crossinline instantiate: () -> F)

เปิดใช้ Fragment ที่มีอาร์กิวเมนต์ที่ระบุซึ่งโฮสต์โดย FragmentActivity ที่ว่างเปล่าโดยใช้ instantiate เพื่อสร้าง Fragment และรอให้ Fragment เข้าสู่สถานะ "กลับมาทำงานต่อ"

FragmentScenario<F!> launchFragmentInContainer(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, factory: FragmentFactory? = null)

เปิด Fragment ในคอนเทนเนอร์มุมมองรากของกิจกรรม android.R.id.content โดยมี อาร์กิวเมนต์ที่ระบุซึ่งโฮสต์โดย FragmentActivity ที่ว่างเปล่า และรอให้ Fragment ดังกล่าวเข้าสู่สถานะ กลับมาทำงานต่อ

FragmentScenario<F!> launchFragmentInContainer(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, crossinline instantiate: () -> F)

เปิด Fragment ในคอนเทนเนอร์มุมมองรากของ Activity android.R.id.content โดยมี อาร์กิวเมนต์ที่กำหนดซึ่งโฮสต์โดย FragmentActivity ที่ว่างเปล่าโดยใช้ instantiate เพื่อสร้าง Fragment และรอให้ Fragment เข้าสู่สถานะ กลับมาทำงานต่อ

androidx.lifecycle

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.lifecycle:lifecycle-livedata-core-ktx:2.9.2"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.9.2"
    implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:2.9.2"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.9.2"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.2"
}

Kotlin

dependencies {
    implementation("androidx.lifecycle:lifecycle-livedata-core-ktx:2.9.2")
    implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.9.2")
    implementation("androidx.lifecycle:lifecycle-reactivestreams-ktx:2.9.2")
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.9.2")
    implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.2")
}

ฟังก์ชันของส่วนขยาย

สำหรับ kotlinx.coroutines.flow.Flow
LiveData<T> Flow<T>.asLiveData(context: CoroutineContext = EmptyCoroutineContext, timeoutInMs: Long = DEFAULT_TIMEOUT)

สร้าง LiveData ที่มีค่าที่รวบรวมจาก Flow ต้นทาง

LiveData<T> Flow<T>.asLiveData(context: CoroutineContext = EmptyCoroutineContext, timeout: Duration)

สร้าง LiveData ที่มีค่าที่รวบรวมจาก Flow ต้นทาง

สำหรับ org.reactivestreams.Publisher
LiveData<T> Publisher<T>.toLiveData()

สร้างสตรีม LiveData ที่สังเกตได้จาก Publisher ของ ReactiveStreams

สำหรับ LiveData
โฟลว์<T> LiveData<T>.asFlow()

สร้าง Flow ที่มีค่าซึ่งส่งโดย LiveData ต้นทาง: เมื่อเริ่มต้น ตัวรวบรวม Flow จะได้รับค่าล่าสุดที่ LiveData เก็บไว้ จากนั้นจะสังเกตการอัปเดต LiveData

LiveData<X> LiveData<X>.distinctUntilChanged()

สร้างออบเจ็กต์ LiveData ใหม่ซึ่งจะไม่ปล่อยค่าจนกว่าจะมีการเปลี่ยนแปลงthis ค่า LiveData ของแหล่งที่มา

LiveData<Y> LiveData<X>.map(crossinline transform: (X) -> Y)

แสดงผล LiveData ที่แมปจาก this LiveData โดยใช้ transform กับแต่ละค่าที่ตั้งค่าไว้ใน this LiveData

Observer<T> LiveData<T>.observe(owner: LifecycleOwner, crossinline onChanged: (T) -> Unit)

เพิ่ม Lambda onChanged ที่ระบุเป็น Observer ภายในช่วงอายุของ owner ที่ระบุ และส่งคืนการอ้างอิงไปยัง Observer

LiveData<Y> LiveData<X>.switchMap(crossinline transform: (X) -> LiveData<Y>)

แสดงผล LiveData ที่แมปจาก this LiveData โดยใช้ transform กับชุดค่าแต่ละชุดที่ตั้งค่าไว้ใน this

ผู้เผยแพร่โฆษณา<T> LiveData<T>.toPublisher(lifecycle: LifecycleOwner)

ปรับสตรีม LiveData ที่ระบุให้เป็น Publisher ของ ReactiveStreams

สำหรับ ViewModelProvider
VM ViewModelProvider.get()

ส่งคืน ViewModel ที่มีอยู่หรือสร้าง ViewModel ใหม่ในขอบเขต (โดยปกติคือ Fragment หรือ Activity) ที่เชื่อมโยงกับ ViewModelProvider นี้

สำหรับ LifecycleOwner
ระงับ T LifecycleOwner.whenCreated(block: suspend CoroutineScope.() -> T)

เรียกใช้บล็อกที่ระบุเมื่อ LifecycleOwner มี Lifecycle อยู่ในสถานะ Lifecycle.State.CREATED เป็นอย่างน้อย

ระงับ T LifecycleOwner.whenResumed(block: suspend CoroutineScope.() -> T)

เรียกใช้บล็อกที่ระบุเมื่อ LifecycleOwner มี Lifecycle อยู่ในสถานะ Lifecycle.State.RESUMED เป็นอย่างน้อย

ระงับ T LifecycleOwner.whenStarted(block: suspend CoroutineScope.() -> T)

เรียกใช้บล็อกที่ระบุเมื่อ LifecycleOwner มี Lifecycle อยู่ในสถานะ Lifecycle.State.STARTED เป็นอย่างน้อย

สำหรับวงจร
ระงับ T Lifecycle.whenCreated(block: suspend CoroutineScope.() -> T)

เรียกใช้บล็อกที่ระบุเมื่อ Lifecycle อยู่ในสถานะ Lifecycle.State.CREATED อย่างน้อย

ระงับ T Lifecycle.whenResumed(block: suspend CoroutineScope.() -> T)

เรียกใช้บล็อกที่ระบุเมื่อ Lifecycle อยู่ในสถานะ Lifecycle.State.RESUMED อย่างน้อย

ระงับ T Lifecycle.whenStarted(block: suspend CoroutineScope.() -> T)

เรียกใช้บล็อกที่ระบุเมื่อ Lifecycle อยู่ในสถานะ Lifecycle.State.STARTED เป็นอย่างน้อย

ระงับ T Lifecycle.whenStateAtLeast(minState: Lifecycle.State, block: suspend CoroutineScope.() -> T)

เรียกใช้บล็อกที่ระบุใน CoroutineDispatcher ที่เรียกใช้บล็อกในเทรดหลัก และระงับการดำเนินการจนกว่าสถานะของ Lifecycle จะเป็น minState เป็นอย่างน้อย

คุณสมบัติของส่วนขยาย

สำหรับวงจร
LifecycleCoroutineScope Lifecycle.coroutineScope()

CoroutineScope ที่เชื่อมโยงกับ Lifecycle นี้

สำหรับ LifecycleOwner
LifecycleCoroutineScope LifecycleOwner.lifecycleScope()

CoroutineScope ที่เชื่อมโยงกับ Lifecycle ของ LifecycleOwner นี้

สำหรับ ViewModel
CoroutineScope ViewModel.viewModelScope()

CoroutineScope ที่เชื่อมโยงกับ ViewModel นี้

ฟังก์ชันระดับบนสุด

LiveData<T> liveData(context: CoroutineContext = EmptyCoroutineContext, timeoutInMs: Long = DEFAULT_TIMEOUT, block: suspend LiveDataScope<T>.() -> Unit)

สร้าง LiveData ที่มีค่าที่ได้จากบล็อกที่กำหนดซึ่งดำเนินการใน LiveDataScope

LiveData<T> liveData(context: CoroutineContext = EmptyCoroutineContext, timeout: Duration, block: suspend LiveDataScope<T>.() -> Unit)

สร้าง LiveData ที่มีค่าที่ได้จากบล็อกที่กำหนดซึ่งดำเนินการใน LiveDataScope

androidx.navigation

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.navigation:navigation-runtime-ktx:2.9.3"
    implementation "androidx.navigation:navigation-fragment-ktx:2.9.3"
    implementation "androidx.navigation:navigation-ui-ktx:2.9.3"
}

Kotlin

dependencies {
    implementation("androidx.navigation:navigation-runtime-ktx:2.9.3")
    implementation("androidx.navigation:navigation-fragment-ktx:2.9.3")
    implementation("androidx.navigation:navigation-ui-ktx:2.9.3")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.app.Activity
NavController Activity.findNavController(@IdRes viewId: Int)

ค้นหา NavController โดยระบุรหัสของ View และ Activity ที่มี View นั้น

NavArgsLazy<Args> Activity.navArgs()

แสดงผลตัวแทน Lazy เพื่อเข้าถึงส่วนเสริมของกิจกรรมเป็นอินสแตนซ์ Args

สำหรับ android.view.View
NavController View.findNavController()

ค้นหา NavController ที่เชื่อมโยงกับ View

สำหรับ NavGraphBuilder
หน่วย NavGraphBuilder.activity(@IdRes id: Int, builder: ActivityNavigatorDestinationBuilder.() -> Unit)

สร้าง ActivityNavigator.Destination ใหม่

หน่วย NavGraphBuilder.navigation(@IdRes id: Int, @IdRes startDestination: Int, builder: NavGraphBuilder.() -> Unit)

สร้าง NavGraph ที่ซ้อนกัน

สำหรับ NavGraph
ตัวดำเนินการ บูลีน NavGraph.contains(@IdRes id: Int)

แสดงผล true หากพบปลายทางที่มี id ในกราฟการนำทางนี้

operator NavDestination NavGraph.get(@IdRes id: Int)

แสดงผลปลายทางด้วย id

โอเปอเรเตอร์ Unit NavGraph.minusAssign(node: NavDestination)

นำ node ออกจากกราฟการนำทางนี้

โอเปอเรเตอร์ Unit NavGraph.plusAssign(node: NavDestination)

เพิ่มปลายทางไปยัง NavGraph นี้

โอเปอเรเตอร์ Unit NavGraph.plusAssign(other: NavGraph)

เพิ่มปลายทางทั้งหมดจากคอลเล็กชันอื่นไปยังคอลเล็กชันนี้

สำหรับ NavController
NavGraph NavController.createGraph(@IdRes id: Int = 0, @IdRes startDestination: Int, builder: NavGraphBuilder.() -> Unit)

สร้าง NavGraph ใหม่

สำหรับ NavHost
NavGraph NavHost.createGraph(@IdRes id: Int = 0, @IdRes startDestination: Int, builder: NavGraphBuilder.() -> Unit)

สร้าง NavGraph ใหม่

สำหรับ NavigatorProvider
operator T NavigatorProvider.get(name: String)

เรียกข้อมูล Navigator ที่ลงทะเบียนตามชื่อ

operator T NavigatorProvider.get(clazz: KClass<T>)

เรียกข้อมูล Navigator ที่ลงทะเบียนโดยใช้ชื่อที่ระบุโดย คำอธิบายประกอบ Navigator.Name

NavGraph NavigatorProvider.navigation(@IdRes id: Int = 0, @IdRes startDestination: Int, builder: NavGraphBuilder.() -> Unit)

สร้าง NavGraph ใหม่

โอเปอเรเตอร์ Unit NavigatorProvider.plusAssign(navigator: Navigator<out NavDestination>)

ลงทะเบียน Navigator โดยใช้ชื่อที่ระบุโดย คำอธิบายประกอบ Navigator.Name

operator Navigator<out NavDestination!>? NavigatorProvider.set(name: String, navigator: Navigator<out NavDestination>)

ลงทะเบียน Navigator ตามชื่อ

สำหรับ Fragment
Lazy<VM> Fragment.navGraphViewModels(@IdRes navGraphId: Int, noinline factoryProducer: () -> ViewModelProvider.Factory = null)

ส่งคืนตัวแทนพร็อพเพอร์ตี้เพื่อเข้าถึง ViewModel ที่กำหนดขอบเขตไว้ในกราฟการนำทางที่อยู่ในสแต็กย้อนกลับของ {@link NavController} ดังนี้

ฟังก์ชันระดับบนสุด

ActivityNavigator.Extras ActivityNavigatorExtras(activityOptions: ActivityOptionsCompat? = null, flags: Int = 0)

สร้างอินสแตนซ์ ActivityNavigator.Extras ใหม่ด้วยอินสแตนซ์ ActivityOptionsCompat ที่เฉพาะเจาะจงและ/หรือ Flag Intent.FLAG_ACTIVITY_

NavOptions navOptions(optionsBuilder: NavOptionsBuilder.() -> Unit)

สร้าง NavOptions ใหม่

androidx.navigation.fragment

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.navigation:navigation-fragment-ktx:2.9.3"
}

Kotlin

dependencies {
    implementation("androidx.navigation:navigation-fragment-ktx:2.9.3")
}

ฟังก์ชันของส่วนขยาย

สำหรับ NavGraphBuilder
หน่วย NavGraphBuilder.dialog(@IdRes id: Int)

สร้าง DialogFragmentNavigator.Destination ใหม่

หน่วย NavGraphBuilder.dialog(@IdRes id: Int, builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit)

สร้าง DialogFragmentNavigator.Destination ใหม่

หน่วย NavGraphBuilder.fragment(@IdRes id: Int)

สร้าง FragmentNavigator.Destination ใหม่

หน่วย NavGraphBuilder.fragment(@IdRes id: Int, builder: FragmentNavigatorDestinationBuilder.() -> Unit)

สร้าง FragmentNavigator.Destination ใหม่

สำหรับ Fragment
NavController Fragment.findNavController()

ค้นหา NavController ที่กำหนด Fragment

NavArgsLazy<Args> Fragment.navArgs()

แสดงผลตัวแทน Lazy เพื่อเข้าถึงอาร์กิวเมนต์ของ Fragment เป็นอินสแตนซ์ Args

ฟังก์ชันระดับบนสุด

FragmentNavigator.Extras FragmentNavigatorExtras(vararg sharedElements: Pair<View, String>)

สร้างอินสแตนซ์ FragmentNavigator.Extras ใหม่ด้วยองค์ประกอบที่แชร์ที่ระบุ

androidx.navigation.ui

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.navigation:navigation-ui-ktx:2.9.3"
}

Kotlin

dependencies {
    implementation("androidx.navigation:navigation-ui-ktx:2.9.3")
}

ฟังก์ชันของส่วนขยาย

สำหรับ android.view.MenuItem
บูลีน MenuItem.onNavDestinationSelected(navController: NavController)

พยายามไปยัง NavDestination ที่เชื่อมโยงกับ MenuItem นี้

สำหรับ androidx.appcompat.app.AppCompatActivity
หน่วย AppCompatActivity.setupActionBarWithNavController(navController: NavController, drawerLayout: DrawerLayout?)

ตั้งค่า ActionBar ที่ส่งคืนโดย AppCompatActivity.getSupportActionBar เพื่อใช้ กับ NavController

หน่วย AppCompatActivity.setupActionBarWithNavController(navController: NavController, configuration: AppBarConfiguration = AppBarConfiguration(navController.graph))

ตั้งค่า ActionBar ที่ส่งคืนโดย AppCompatActivity.getSupportActionBar เพื่อใช้ กับ NavController

สำหรับ androidx.appcompat.widget.Toolbar
หน่วย Toolbar.setupWithNavController(navController: NavController, drawerLayout: DrawerLayout?)

ตั้งค่าแถบเครื่องมือเพื่อใช้กับ NavController

หน่วย Toolbar.setupWithNavController(navController: NavController, configuration: AppBarConfiguration = AppBarConfiguration(navController.graph))

ตั้งค่าแถบเครื่องมือเพื่อใช้กับ NavController

สำหรับ com.google.android.material.appbar.CollapsingToolbarLayout
หน่วย CollapsingToolbarLayout.setupWithNavController(toolbar: Toolbar, navController: NavController, drawerLayout: DrawerLayout?)

ตั้งค่า CollapsingToolbarLayout และ Toolbar เพื่อใช้กับ NavController

หน่วย CollapsingToolbarLayout.setupWithNavController(toolbar: Toolbar, navController: NavController, configuration: AppBarConfiguration = AppBarConfiguration(navController.graph))

ตั้งค่า CollapsingToolbarLayout และ Toolbar เพื่อใช้กับ NavController

สำหรับ com.google.android.material.bottomnavigation.BottomNavigationView
หน่วย BottomNavigationView.setupWithNavController(navController: NavController)

ตั้งค่า BottomNavigationView เพื่อใช้กับ NavController

สำหรับ com.google.android.material.navigation.NavigationView
หน่วย NavigationView.setupWithNavController(navController: NavController)

ตั้งค่า NavigationView เพื่อใช้กับ NavController

สำหรับ NavController
บูลีน NavController.navigateUp(drawerLayout: DrawerLayout?)

จัดการปุ่มขึ้นโดยมอบหมายลักษณะการทำงานให้กับ NavController ที่ระบุ

บูลีน NavController.navigateUp(appBarConfiguration: AppBarConfiguration)

จัดการปุ่มขึ้นโดยมอบหมายลักษณะการทำงานให้กับ NavController ที่ระบุ

ฟังก์ชันระดับบนสุด

AppBarConfiguration AppBarConfiguration(navGraph: NavGraph, drawerLayout: DrawerLayout? = null, noinline fallbackOnNavigateUpListener: () -> Boolean = { false })

ตัวเลือกการกำหนดค่าสำหรับเมธอด NavigationUI ที่โต้ตอบกับการใช้งานรูปแบบแถบแอป เช่น android.support.v7.widget.Toolbar, android.support.design.widget.CollapsingToolbarLayout และ android.support.v7.app.ActionBar

AppBarConfiguration AppBarConfiguration(topLevelMenu: Menu, drawerLayout: DrawerLayout? = null, noinline fallbackOnNavigateUpListener: () -> Boolean = { false })

ตัวเลือกการกำหนดค่าสำหรับเมธอด NavigationUI ที่โต้ตอบกับการใช้งานรูปแบบแถบแอป เช่น android.support.v7.widget.Toolbar, android.support.design.widget.CollapsingToolbarLayout และ android.support.v7.app.ActionBar

AppBarConfiguration AppBarConfiguration(topLevelDestinationIds: Set<Int>, drawerLayout: DrawerLayout? = null, noinline fallbackOnNavigateUpListener: () -> Boolean = { false })

ตัวเลือกการกำหนดค่าสำหรับเมธอด NavigationUI ที่โต้ตอบกับการใช้งานรูปแบบแถบแอป เช่น android.support.v7.widget.Toolbar, android.support.design.widget.CollapsingToolbarLayout และ android.support.v7.app.ActionBar

androidx.paging

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.paging:paging-common-ktx:2.1.2"
    implementation "androidx.paging:paging-runtime-ktx:2.1.2"
    implementation "androidx.paging:paging-rxjava2-ktx:2.1.2"
}

Kotlin

dependencies {
    implementation("androidx.paging:paging-common-ktx:2.1.2")
    implementation("androidx.paging:paging-runtime-ktx:2.1.2")
    implementation("androidx.paging:paging-rxjava2-ktx:2.1.2")
}

ฟังก์ชันของส่วนขยาย

สำหรับโรงงาน
Flowable<PagedList<Value>> DataSource.Factory<Key, Value>.toFlowable(config: PagedList.Config, initialLoadKey: Key? = null, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, fetchScheduler: Scheduler? = null, notifyScheduler: Scheduler? = null, backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST)

สร้าง Flowable<PagedList> จาก DataSource.Factory นี้เพื่อความสะดวกสำหรับ RxPagedListBuilder

Flowable<PagedList<Value>> DataSource.Factory<Key, Value>.toFlowable(pageSize: Int, initialLoadKey: Key? = null, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, fetchScheduler: Scheduler? = null, notifyScheduler: Scheduler? = null, backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST)

สร้าง Flowable<PagedList> จาก DataSource.Factory นี้เพื่อความสะดวกสำหรับ RxPagedListBuilder

LiveData<PagedList<Value>> DataSource.Factory<Key, Value>.toLiveData(config: PagedList.Config, initialLoadKey: Key? = null, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, fetchExecutor: Executor = ArchTaskExecutor.getIOThreadExecutor())

สร้าง LiveData<PagedList> จาก DataSource.Factory นี้เพื่อความสะดวกสำหรับ LivePagedListBuilder

LiveData<PagedList<Value>> DataSource.Factory<Key, Value>.toLiveData(pageSize: Int, initialLoadKey: Key? = null, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, fetchExecutor: Executor = ArchTaskExecutor.getIOThreadExecutor())

สร้าง LiveData<PagedList> จาก DataSource.Factory นี้เพื่อความสะดวกสำหรับ LivePagedListBuilder

Observable<PagedList<Value>> DataSource.Factory<Key, Value>.toObservable(config: PagedList.Config, initialLoadKey: Key? = null, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, fetchScheduler: Scheduler? = null, notifyScheduler: Scheduler? = null)

สร้าง Observable<PagedList> จาก DataSource.Factory นี้เพื่อความสะดวกสำหรับ RxPagedListBuilder

Observable<PagedList<Value>> DataSource.Factory<Key, Value>.toObservable(pageSize: Int, initialLoadKey: Key? = null, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, fetchScheduler: Scheduler? = null, notifyScheduler: Scheduler? = null)

สร้าง Observable<PagedList> จาก DataSource.Factory นี้เพื่อความสะดวกสำหรับ RxPagedListBuilder

ฟังก์ชันระดับบนสุด

PagedList.Config Config(pageSize: Int, prefetchDistance: Int = pageSize, enablePlaceholders: Boolean = true, initialLoadSizeHint: Int = pageSize * PagedList.Config.Builder.DEFAULT_INITIAL_PAGE_MULTIPLIER, maxSize: Int = PagedList.Config.MAX_SIZE_UNBOUNDED)

สร้าง PagedList.Config เพื่อความสะดวกสำหรับ PagedList.Config.Builder

PagedList<Value> PagedList(dataSource: DataSource<Key, Value>, config: PagedList.Config, notifyExecutor: Executor, fetchExecutor: Executor, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, initialKey: Key? = null)

สร้าง PagedList เพื่อความสะดวกสำหรับ PagedList.Builder

androidx.palette.graphics

การขึ้นต่อกัน

ดึงดูด

dependencies {
    implementation "androidx.palette:palette-ktx:1.0.0"
}

Kotlin

dependencies {
    implementation("androidx.palette:palette-ktx:1.0.0")
}

ฟังก์ชันของส่วนขยาย

สำหรับ Palette
operator Palette.Swatch? Palette.get(target: Target)

แสดงตัวอย่างสีที่เลือกสำหรับเป้าหมายที่ระบุจากจานสี หรือ null หากไม่พบ

androidx.preference

การขึ้นต่อกัน

ดึงดูด

dependencies {
    implementation "androidx.preference:preference-ktx:1.2.1"
}

Kotlin

dependencies {
    implementation("androidx.preference:preference-ktx:1.2.1")
}

ฟังก์ชันของส่วนขยาย

สำหรับ PreferenceGroup
ตัวดำเนินการ บูลีน PreferenceGroup.contains(preference: Preference)

แสดงผล true หากพบ preference ในกลุ่มค่ากำหนดนี้

หน่วย PreferenceGroup.forEach(action: (preference: Preference) -> Unit)

ดำเนินการที่ระบุกับค่ากำหนดแต่ละรายการในกลุ่มค่ากำหนดนี้

หน่วย PreferenceGroup.forEachIndexed(action: (index: Int, preference: Preference) -> Unit)

ดำเนินการที่ระบุกับค่ากำหนดแต่ละรายการในกลุ่มค่ากำหนดนี้ โดยระบุดัชนีตามลำดับ

โอเปอเรเตอร์ T? PreferenceGroup.get(key: CharSequence)

แสดงค่ากำหนดที่มี key หรือ null หากไม่พบค่ากำหนดที่มี key

โอเปอเรเตอร์ ค่ากำหนด PreferenceGroup.get(index: Int)

แสดงค่ากำหนดที่ index

บูลีน PreferenceGroup.isEmpty()

แสดงค่าเป็นจริงหากกลุ่มค่ากำหนดนี้ไม่มีค่ากำหนด

บูลีน PreferenceGroup.isNotEmpty()

แสดงค่าเป็นจริงหากกลุ่มค่ากําหนดนี้มีค่ากําหนดอย่างน้อย 1 รายการ

operator MutableIterator<Preference> PreferenceGroup.iterator()

แสดง MutableIterator สำหรับค่ากำหนดในกลุ่มค่ากำหนดนี้

โอเปอเรเตอร์ Unit PreferenceGroup.minusAssign(preference: Preference)

นำ preference ออกจากกลุ่มค่ากำหนดนี้

โอเปอเรเตอร์ Unit PreferenceGroup.plusAssign(preference: Preference)

เพิ่ม preference ลงในกลุ่มค่ากำหนดนี้

คุณสมบัติของส่วนขยาย

สำหรับ PreferenceGroup
ลำดับ<Preference> PreferenceGroup.children()

แสดงผล Sequence ของค่ากำหนดในกลุ่มค่ากำหนดนี้

Int PreferenceGroup.size()

แสดงผลจำนวนค่ากำหนดในกลุ่มค่ากำหนดนี้

androidx.room

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.room:room-ktx:2.7.2"
}

Kotlin

dependencies {
    implementation("androidx.room:room-ktx:2.7.2")
}

ฟังก์ชันของส่วนขยาย

สำหรับ RoomDatabase
ระงับ R RoomDatabase.withTransaction(block: suspend () -> R)

เรียกใช้บล็อกการระงับที่ระบุในธุรกรรมฐานข้อมูล

androidx.slice.builders

การขึ้นต่อกัน

ดึงดูด

dependencies {
    implementation "androidx.slice:slice-builders-ktx:1.0.0-alpha08"
}

Kotlin

dependencies {
    implementation("androidx.slice:slice-builders-ktx:1.0.0-alpha08")
}

ฟังก์ชันของส่วนขยาย

สำหรับ GridRowBuilderDsl
GridRowBuilder GridRowBuilderDsl.cell(buildCell: CellBuilderDsl.() -> Unit)

GridRowBuilder GridRowBuilderDsl.seeMoreCell(buildCell: CellBuilderDsl.() -> Unit)

สำหรับ ListBuilderDsl
ListBuilder ListBuilderDsl.gridRow(buildGrid: GridRowBuilderDsl.() -> Unit)

ListBuilder ListBuilderDsl.header(buildHeader: HeaderBuilderDsl.() -> Unit)

ListBuilder ListBuilderDsl.inputRange(buildInputRange: InputRangeBuilderDsl.() -> Unit)

ListBuilder ListBuilderDsl.range(buildRange: RangeBuilderDsl.() -> Unit)

ListBuilder ListBuilderDsl.row(buildRow: RowBuilderDsl.() -> Unit)

ListBuilder ListBuilderDsl.seeMoreRow(buildRow: RowBuilderDsl.() -> Unit)

ฟังก์ชันระดับบนสุด

สไลซ์ list(context: Context, uri: Uri, ttl: Long, addRows: ListBuilderDsl.() -> Unit)

ลดความละเอียดที่จำเป็นในการสร้าง Slice ใน Kotlin

SliceAction tapSliceAction(pendingIntent: PendingIntent, icon: IconCompat, imageMode: Int = ICON_IMAGE, title: CharSequence)

เมธอด Factory สำหรับสร้าง SliceAction ที่แตะได้

SliceAction toggleSliceAction(pendingIntent: PendingIntent, icon: IconCompat? = null, title: CharSequence, isChecked: Boolean)

เมธอด Factory สำหรับสร้าง SliceAction ที่สลับได้

androidx.sqlite.db

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "androidx.sqlite:sqlite-ktx:2.5.2"
}

Kotlin

dependencies {
    implementation("androidx.sqlite:sqlite-ktx:2.5.2")
}

ฟังก์ชันของส่วนขยาย

สำหรับ SupportSQLiteDatabase
T SupportSQLiteDatabase.transaction(exclusive: Boolean = true, body: SupportSQLiteDatabase.() -> T)

เรียกใช้ body ในธุรกรรมโดยทำเครื่องหมายว่าสำเร็จหากเสร็จสมบูรณ์โดยไม่มีข้อยกเว้น

androidx.work

การขึ้นต่อกัน

ฟังก์ชันของส่วนขยาย

สำหรับ com.google.common.util.concurrent.ListenableFuture
ระงับ R ListenableFuture<R>.await()

รอให้ ListenableFuture เสร็จสมบูรณ์โดยไม่บล็อกเธรด

สำหรับการดำเนินการ
suspend Operation.State.SUCCESS! Operation.await()

รอ Operation โดยไม่บล็อกเทรด

สำหรับ Data
บูลีน Data.hasKeyWithValueOfType(key: String)

แสดงผลเป็นจริงหากอินสแตนซ์ของ Data มีค่าที่สอดคล้องกับ key ที่ระบุโดยมี ประเภท T ที่คาดไว้

สำหรับผู้สร้าง
OneTimeWorkRequest.Builder OneTimeWorkRequest.Builder.setInputMerger(@NonNull inputMerger: KClass<out InputMerger>)

ตั้งค่า InputMerger ใน OneTimeWorkRequest.Builder

ฟังก์ชันระดับบนสุด

OneTimeWorkRequest.Builder OneTimeWorkRequestBuilder()

สร้าง OneTimeWorkRequest ด้วย ListenableWorker ที่ระบุ

PeriodicWorkRequest.Builder PeriodicWorkRequestBuilder(repeatInterval: Long, repeatIntervalTimeUnit: TimeUnit)

สร้าง PeriodicWorkRequest.Builder ด้วย ListenableWorker ที่ระบุ

PeriodicWorkRequest.Builder PeriodicWorkRequestBuilder(repeatInterval: Duration)

สร้าง PeriodicWorkRequest.Builder ด้วย ListenableWorker ที่ระบุ

PeriodicWorkRequest.Builder PeriodicWorkRequestBuilder(repeatInterval: Long, repeatIntervalTimeUnit: TimeUnit, flexTimeInterval: Long, flexTimeIntervalUnit: TimeUnit)

สร้าง PeriodicWorkRequest.Builder ด้วย ListenableWorker ที่ระบุ

PeriodicWorkRequest.Builder PeriodicWorkRequestBuilder(repeatInterval: Duration, flexTimeInterval: Duration)

สร้าง PeriodicWorkRequest.Builder ด้วย ListenableWorker ที่ระบุ

ข้อมูล workDataOf(vararg pairs: Pair<String, Any?>)

แปลงรายการคู่เป็นออบเจ็กต์ข้อมูล

androidx.work.testing

การขึ้นต่อกัน

ดึงดูด

dependencies {
    implementation "androidx.work:work-testing:2.10.3"
}

Kotlin

dependencies {
    implementation("androidx.work:work-testing:2.10.3")
}

ฟังก์ชันระดับบนสุด

TestListenableWorkerBuilder<W> TestListenableWorkerBuilder(context: Context, inputData: Data = Data.EMPTY, tags: List<String> = emptyList(), runAttemptCount: Int = 1, triggeredContentUris: List<Uri> = emptyList(), triggeredContentAuthorities: List<String> = emptyList())

สร้างอินสแตนซ์ของ TestListenableWorkerBuilder

TestWorkerBuilder<W> TestWorkerBuilder(context: Context, executor: Executor, inputData: Data = Data.EMPTY, tags: List<String> = emptyList(), runAttemptCount: Int = 1, triggeredContentUris: List<Uri> = emptyList(), triggeredContentAuthorities: List<String> = emptyList())

สร้างอินสแตนซ์ของ TestWorkerBuilder

com.google.android.play.core.ktx

การขึ้นต่อกัน

Groovy

dependencies {
    implementation "com.google.android.play:core-ktx:1.8.1"
}

Kotlin

dependencies {
    implementation("com.google.android.play:core-ktx:1.8.1")
}

ฟังก์ชันของส่วนขยาย

สำหรับ com.google.android.play.core.appupdate.AppUpdateManager
suspend AppUpdateInfo AppUpdateManager.requestAppUpdateInfo()

ขอความพร้อมในการอัปเดตสำหรับแอปปัจจุบัน

ระงับ หน่วย AppUpdateManager.requestCompleteUpdate()

สำหรับขั้นตอนการอัปเดตที่ยืดหยุ่น จะทริกเกอร์การอัปเดตให้เสร็จสมบูรณ์

Flow<AppUpdateResult> AppUpdateManager.requestUpdateFlow()

จุดแรกเข้าสำหรับการตรวจสอบความพร้อมใช้งานและความคืบหน้าของการอัปเดต

บูลีน AppUpdateManager.startUpdateFlowForResult(appUpdateInfo: AppUpdateInfo, appUpdateType: Int, fragment: Fragment, requestCode: Int)

เวอร์ชันของ AppUpdateManager.startUpdateFlowForResult ที่ยอมรับ AndroidX Fragment สำหรับการแสดงผลลัพธ์

สำหรับ com.google.android.play.core.splitinstall.SplitInstallManager
ระงับ หน่วย SplitInstallManager.requestCancelInstall(sessionId: Int)

เวอร์ชันที่ระงับของ SplitInstallManager.cancelInstall

ระงับ หน่วย SplitInstallManager.requestDeferredInstall(moduleNames: List<String>)

ระงับเวอร์ชันของ SplitInstallManager.deferredInstall

ระงับ หน่วย SplitInstallManager.requestDeferredLanguageInstall(languages: List<Locale>)

ระงับเวอร์ชันของ SplitInstallManager.deferredLanguageInstall

ระงับ หน่วย SplitInstallManager.requestDeferredLanguageUninstall(languages: List<Locale>)

ระงับเวอร์ชันของ SplitInstallManager.deferredLanguageUninstall

ระงับ หน่วย SplitInstallManager.requestDeferredUninstall(moduleNames: List<String>)

ระงับเวอร์ชันของ SplitInstallManager.deferredUninstall

ระงับ Int SplitInstallManager.requestInstall(modules: List<String> = listOf(), languages: List<String> = listOf())

เริ่มการติดตั้งโมดูล/ภาษาที่ขอ

โฟลว์<SplitInstallSessionState> SplitInstallManager.requestProgressFlow()

สร้างและแสดงผล Flow ที่บัฟเฟอร์ไว้ซึ่งจะ ส่งมอบเหตุการณ์ความคืบหน้าทั้งหมดสำหรับการติดตั้งแบบแยกที่กำลังดำเนินการ

suspend SplitInstallSessionState SplitInstallManager.requestSessionState(sessionId: Int)

ระงับเวอร์ชันของ SplitInstallManager.getSessionState

suspend List<SplitInstallSessionState> SplitInstallManager.requestSessionStates()

ระงับเวอร์ชันของ SplitInstallManager.getSessionStates

บูลีน SplitInstallManager.startConfirmationDialogForResult(sessionState: SplitInstallSessionState, fragment: Fragment, requestCode: Int)

เวอร์ชันของ SplitInstallManager.startConfirmationDialogForResult ที่ยอมรับ AndroidX Fragment สำหรับการแสดงผลลัพธ์

คุณสมบัติของส่วนขยาย

สำหรับ com.google.android.play.core.appupdate.AppUpdateInfo
Int AppUpdateInfo.installStatus()

แสดงสถานะความคืบหน้าของการอัปเดต

บูลีน AppUpdateInfo.isFlexibleUpdateAllowed()

แสดง true หากอนุญาตการอัปเดตที่ยืดหยุ่น

บูลีน AppUpdateInfo.isImmediateUpdateAllowed()

แสดงผล true หากอนุญาตให้อัปเดตทันที

สำหรับ com.google.android.play.core.install.InstallState
บูลีน InstallState.hasTerminalStatus()

ซึ่งหมายความว่านี่คือสถานะสุดท้าย (จะไม่มีการอัปเดตอีก) และควรจัดการตามนั้น (สำเร็จ ยกเลิก หรือล้มเหลว)

Int InstallState.installErrorCode()

แสดงรหัสข้อผิดพลาดสำหรับการติดตั้ง หรือ {@link InstallErrorCode#NO_ERROR}

Int InstallState.installStatus()

แสดงสถานะการติดตั้ง

สตริง! InstallState.packageName()

แสดงชื่อแพ็กเกจของแอปที่กำลังติดตั้ง

สำหรับ com.google.android.play.core.splitinstall.SplitInstallSessionState
ยาว SplitInstallSessionState.bytesDownloaded()

ไบต์ที่ดาวน์โหลดโดยการอัปเดตนี้

Int SplitInstallSessionState.errorCode()

รหัสข้อผิดพลาดของการอัปเดตนี้

บูลีน SplitInstallSessionState.hasTerminalStatus()

ระบุว่าการอัปเดตนี้เป็นเทอร์มินัล ซึ่งหมายความว่าจะไม่มีการอัปเดตเพิ่มเติมสำหรับเซสชันนี้

List<String> SplitInstallSessionState.languages()

ภาษาที่รวมอยู่ในการอัปเดตนี้

List<String> SplitInstallSessionState.moduleNames()

โมดูลที่รวมอยู่ในการอัปเดตนี้

Int SplitInstallSessionState.sessionId()

รหัสเซสชันของการอัปเดตนี้

Int SplitInstallSessionState.status()

รหัสสถานะของการอัปเดตนี้

ยาว SplitInstallSessionState.totalBytesToDownload()

จำนวนไบต์ทั้งหมดที่ต้องดาวน์โหลดในการอัปเดตนี้

ฟังก์ชันระดับบนสุด

SplitInstallStateUpdatedListener SplitInstallStateUpdatedListener(onRequiresConfirmation: (SplitInstallSessionState) -> Unit, onInstalled: (SplitInstallSessionState) -> Unit, onFailed: (SplitInstallSessionState) -> Unit = {}, onPending: (SplitInstallSessionState) -> Unit = {}, onDownloaded: (SplitInstallSessionState) -> Unit = {}, onDownloading: (SplitInstallSessionState) -> Unit = {}, onInstalling: (SplitInstallSessionState) -> Unit = {}, onCanceling: (SplitInstallSessionState) -> Unit = {}, onCanceled: (SplitInstallSessionState) -> Unit = {}, onNonTerminalStatus: (SplitInstallSessionState) -> Unit = {}, onTerminalStatus: (SplitInstallSessionState) -> Unit = {})

ฟังก์ชันอำนวยความสะดวกสำหรับการสร้าง SplitInstallStateUpdatedListener