d0f1b81bfa
#KT-14780 Fixed #KT-14677 Fixed (cherry picked from commit f591b4958e4a836d37d70c2ad8ff15e626c6342a)
42 lines
1.4 KiB
Kotlin
Vendored
42 lines
1.4 KiB
Kotlin
Vendored
// INSPECTION_CLASS: org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintCommitTransactionInspection
|
|
|
|
@file:Suppress("UNUSED_VARIABLE")
|
|
|
|
import android.app.Activity
|
|
import android.app.FragmentTransaction
|
|
import android.app.FragmentManager
|
|
import android.os.Bundle
|
|
|
|
class MainActivity : Activity() {
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
|
|
//OK
|
|
val transaction = fragmentManager.beginTransaction()
|
|
val transaction2: FragmentTransaction
|
|
transaction2 = fragmentManager.beginTransaction()
|
|
transaction.commit()
|
|
transaction2.commit()
|
|
|
|
//WARNING
|
|
val transaction3 = fragmentManager.<warning descr="This transaction should be completed with a `commit()` call">beginTransaction</warning>()
|
|
|
|
//OK
|
|
fragmentManager.beginTransaction().commit()
|
|
fragmentManager.beginTransaction().add(null, "A").commit()
|
|
|
|
//OK KT-14470
|
|
Runnable {
|
|
val a = fragmentManager.beginTransaction()
|
|
a.commit()
|
|
}
|
|
}
|
|
|
|
// KT-14780: Kotlin Lint: "Missing commit() calls" false positive when the result of `commit()` is assigned or used as receiver
|
|
fun testResultOfCommit(fm: FragmentManager) {
|
|
val r1 = fm.beginTransaction().hide(fm.findFragmentByTag("aTag")).commit()
|
|
val r2 = fm.beginTransaction().hide(fm.findFragmentByTag("aTag")).commit().toString()
|
|
}
|
|
}
|