"Fossies" - the Fresh Open Source Software Archive

Member "kotlin-1.3.61/plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fragment/0.kt" (26 Nov 2019, 1066 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.app.Fragment
    5 import android.content.Context
    6 import android.view.View
    7 import android.widget.*
    8 import org.my.cool.MyButton
    9 import kotlinx.android.synthetic.main.layout.*
   10 import kotlinx.android.synthetic.clearFindViewByIdCache
   11 
   12 class R {
   13     class id {
   14         companion object {
   15             const val login = 5
   16         }
   17     }
   18 }
   19 
   20 class BaseView(ctx: Context) : View(ctx) {
   21     val buttonWidget = MyButton(ctx)
   22 
   23     override fun <T : View> findViewById(id: Int): T? {
   24         return when (id) {
   25             R.id.login -> buttonWidget as T
   26             else -> null
   27         }
   28     }
   29 }
   30 
   31 class MyFragment(): Fragment() {
   32     val baseActivity = Activity()
   33     val baseView = BaseView(baseActivity)
   34 
   35     override fun getActivity(): Activity = baseActivity
   36 
   37     override fun getView(): View = baseView
   38 
   39     public fun box(): String {
   40         val result = if (login.toString() == "MyButton") "OK" else ""
   41         clearFindViewByIdCache()
   42         return result
   43     }
   44 }
   45 
   46 fun box(): String {
   47     return MyFragment().box()
   48 }