This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| MainActivityUI(TodoListAdapter()).setContentView(this) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MainActivityUI(val todoListAdapter: TodoListAdapter) : AnkoComponent<MainActivity> { | |
| override fun createView(ui: AnkoContext<MainActivity>) = with(ui) { | |
| verticalLayout { | |
| recyclerView { | |
| val orientation = LinearLayoutManager.VERTICAL | |
| layoutManager = LinearLayoutManager(ctx, orientation, false) | |
| addItemDecoration(DividerItemDecoration(ctx, LinearLayout.VERTICAL)) | |
| adapter = todoListAdapter | |
| }.lparams(width = matchParent, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun EditText.asString(): String = this.text.toString() | |
| fun EditText.clear() { | |
| setText("") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TodoListAdapter(val arrayList: ArrayList<String> = ArrayList<String>()) | |
| : RecyclerView.Adapter<TodoListAdapter.ViewHolder>() { | |
| override fun getItemCount(): Int = arrayList.size | |
| override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | |
| val itemView = TextView(parent.context).apply { | |
| padding = dip(16) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MainActivity : AppCompatActivity() { | |
| val todoListAdapter = TodoListAdapter() | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| verticalLayout { | |
| recyclerView { | |
| val orientation = LinearLayoutManager.VERTICAL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'com.android.application' | |
| apply plugin: 'kotlin-android' | |
| apply plugin: 'kotlin-android-extensions' | |
| android { | |
| compileSdkVersion 25 | |
| buildToolsVersion "25.0.0" | |
| defaultConfig { | |
| applicationId "com.sembozdemir.todokotlin" | |
| minSdkVersion 16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| verticalLayout { | |
| val name = editText() | |
| button("Say Hello") { | |
| onClick { toast("Hello, ${name.text}!") } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'com.android.application' | |
| apply plugin: 'kotlin-android' | |
| apply plugin: 'kotlin-android-extensions' | |
| android { | |
| compileSdkVersion 25 | |
| buildToolsVersion "25.0.0" | |
| defaultConfig { | |
| applicationId "com.sembozdemir.todokotlin" | |
| minSdkVersion 16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Top-level build file where you can add configuration options common to all sub-projects/modules. | |
| buildscript { | |
| ext.kotlin_version = '1.0.5' | |
| repositories { | |
| jcenter() | |
| } | |
| dependencies { | |
| classpath 'com.android.tools.build:gradle:2.2.2' | |
| classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |