"Fossies" - the Fresh Open Source Software Archive

Member "kotlin-1.3.61/plugins/android-extensions/android-extensions-compiler/testData/codegen/android/singleFile/0.kt" (26 Nov 2019, 1243 Bytes) of package /linux/misc/kotlin-1.3.61.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Kotlin source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 package test
    2 
    3 import android.app.Activity
    4 import android.view.View
    5 import android.widget.*
    6 import kotlinx.android.synthetic.main.layout.*
    7 import kotlinx.android.synthetic.clearFindViewByIdCache
    8 
    9 class R {
   10     class id {
   11         companion object {
   12             const val item_detail_container = 0
   13             const val textView1 = 1
   14             const val password = 2
   15             const val textView2 = 3
   16             const val passwordConfirmation = 4
   17             const val login = 5
   18         }
   19     }
   20 }
   21 
   22 class MyActivity(): Activity() {
   23     val textViewWidget = TextView(this)
   24     val editTextWidget = EditText(this)
   25     val buttonWidget = Button(this)
   26 
   27     override fun <T : View> findViewById(id: Int): T? {
   28         return when (id) {
   29             R.id.textView1 -> textViewWidget
   30             R.id.password -> editTextWidget
   31             R.id.login -> buttonWidget
   32             else -> null
   33         } as T?
   34     }
   35 
   36     public fun box(): String {
   37         val result = when {
   38             textView1.toString() == "TextView" && password.toString() == "EditText" && login.toString() == "Button" -> "OK"
   39             else -> ""
   40         }
   41 
   42         clearFindViewByIdCache()
   43 
   44         return result
   45     }
   46 }
   47 
   48 fun box(): String {
   49     return MyActivity().box()
   50 }