{"id":257898,"date":"2015-05-25T17:02:02","date_gmt":"2015-05-25T13:02:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=257898"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=257898","title":{"rendered":"Kotlin \u0434\u043b\u044f Android"},"content":{"rendered":"<p>     \t\u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0438\u0437 \u0442\u0435\u0445, \u043a\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043f\u043e\u0434 Android, \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u043d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b \u043f\u0440\u043e Kotlin. \u041d\u0430 \u0445\u0430\u0431\u0440\u0435 \u043f\u0440\u043e \u043d\u0435\u0433\u043e \u0443\u0436\u0435 \u043f\u0438\u0441\u0430\u043b\u0438: <a href=\"http:\/\/habrahabr.ru\/company\/JetBrains\/blog\/231525\/\">\u0432\u043e\u0442 \u0441\u0442\u0430\u0442\u044c\u044f<\/a>, <a href=\"http:\/\/habrahabr.ru\/company\/e-Legion\/blog\/244999\/\">\u0432\u043e\u0442 \u0432\u0438\u0434\u0435\u043e \u0441 MBLTdev<\/a>. \u042f\u0437\u044b\u043a \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u043d\u043e\u0432\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0432\u0441\u0435 \u043d\u0435\u0442. \u042f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u043f\u043e\u0440\u0430 \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0442\u043e \u0436\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u043d\u0435 \u043e\u0441\u0432\u0435\u0449\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u0445\u0430\u0431\u0440\u0435, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>Anko<\/h4>\n<p>  \u041d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e, \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Kotlin, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043a\u0430 \u0435\u0449\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f (\u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f 0.6). \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h5>Anko DSL<\/h5>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e xml, \u043d\u043e \u0438 \u043f\u0440\u044f\u043c\u043e \u0432 Java-\u043a\u043e\u0434\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u044d\u0442\u043e <s>\u0430\u0434\u0441\u043a\u0430\u044f \u0431\u043e\u043b\u044c<\/s> \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Anko \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043c\u0430\u043b\u043e \u043e\u0431\u0449\u0435\u0433\u043e \u0441 \u0431\u0438\u043b\u0434\u0435\u0440\u0430\u043c\u0438 \u0432 Groovy (\u0432\u043f\u0440\u043e\u0447\u0435\u043c, \u0432 Kotlin \u043e\u043d\u0438 \u0442\u043e\u0436\u0435 <a href=\"http:\/\/kotlinlang.org\/docs\/reference\/type-safe-builders.html\">\u0435\u0441\u0442\u044c<\/a>).<br \/>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 HelloWorld \u0441 xml \u043d\u0430 Anko DSL:  <\/p>\n<pre><code class=\"java\">override fun onCreate(savedInstanceState: Bundle?) {     super.onCreate(savedInstanceState)     relativeLayout {         padding = dip(16)         textView(&quot;Hello world!&quot;) {         }     } } <\/code><\/pre>\n<p>  \u041d\u0435 \u043c\u043e\u0433\u0443 \u043d\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044f \u0441\u0430\u043c \u0431\u044b\u043b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0434\u0438\u0432\u043b\u0435\u043d, \u043a\u043e\u0433\u0434\u0430, \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u044f xml \u0432 Anko DSL, \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u044d\u0442\u0438 5 \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u0438 \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u0441\u0435.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u042d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u0430\u044f xml-\u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"xml\">&lt;RelativeLayout xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;                 android:layout_width=&quot;match_parent&quot;                 android:layout_height=&quot;match_parent&quot;                 android:paddingLeft=&quot;@dimen\/activity_horizontal_margin&quot;                 android:paddingRight=&quot;@dimen\/activity_horizontal_margin&quot;                 android:paddingTop=&quot;@dimen\/activity_vertical_margin&quot;                 android:paddingBottom=&quot;@dimen\/activity_vertical_margin&quot;&gt;      &lt;TextView         android:text=&quot;@string\/hello_world&quot;         android:layout_width=&quot;wrap_content&quot;         android:layout_height=&quot;wrap_content&quot;\/&gt;  &lt;\/RelativeLayout&gt; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e UI:  <\/p>\n<pre><code class=\"java\">override fun onCreate(savedInstanceState: Bundle?) {     super.onCreate(savedInstanceState)     relativeLayout {         padding = dip(16)          val w = dip(200)         val loginEditId = 155;         val loginEdit = editText {             id = loginEditId             hint = &quot;Login&quot;         }.layoutParams { centerInParent(); width = w }          button(&quot;Sign up&quot;) {             textSize = 18f             onClick { doWork(loginEdit.getText().toString()) }         }.layoutParams {             below(loginEditId); sameLeft(loginEditId);             width = w; topMargin = dip(8)         }     } } <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/4ff\/c7f\/537\/4ffc7f537f4b44c0b593158c41fa7e16.png\"\/><\/p>\n<p>  \u0423 Anko DSL \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u2014 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 TextWatcher \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 3 \u043c\u0435\u0442\u043e\u0434\u0430, \u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432\u0441\u0435, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d:  <\/p>\n<pre><code class=\"java\">val edit = EditText(this) edit.addTextChangedListener(object : TextWatcher {     override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {     }      override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {         toast(s)     }      override fun afterTextChanged(s: Editable) {     } }) <\/code><\/pre>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Anko DSL \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e (write as less code as possible):  <\/p>\n<pre><code class=\"java\">val edit = editText {     textChangedListener {         onTextChanged { text, start, before, count -&gt; toast(text.toString()) }     } }.layoutParams { centerInParent() } <\/code><\/pre>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e Anko DSL \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043a\u043e\u0440\u0435\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043e\u0439 xml, \u043d\u043e \u043d\u0435 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0439 \u0437\u0430\u043c\u0435\u043d\u043e\u0439. \u0417\u0430\u043c\u0435\u043d\u043e\u0439 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f UI \u0438\u0437 Java-\u043a\u043e\u0434\u0430. Anko DSL \u043d\u0435 \u0434\u0430\u0435\u0442 \u043e\u0449\u0443\u0442\u0438\u043c\u043e\u0433\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0434\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442. <br \/>  \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Anko DSL \u0445\u043e\u0440\u043e\u0448\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u044b \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 (\u044f \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u044e, \u0447\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u0442\u0438\u043b\u044c \/ \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e xml, \u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 Java \u043a\u043e\u0434\u0435) \u2014 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043b\u044e\u0441 \u043a \u043b\u043e\u0433\u0438\u043a\u0435. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Anko DSL \u0432 \u043c\u043e\u0434\u043d\u043e\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0435 MVP. <br \/>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u043e\u0433\u043e-\u0442\u043e \u0442\u0430\u043a\u043e\u0439 builders-style \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u043c, \u0447\u0435\u043c xml. <br \/>  \u0418 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0432\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u2014 Anko \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0435 \u043a\u0440\u0443\u0442\u044b\u0435 \u0444\u0438\u0447\u0438 \u043e\u0442 \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0430 \u043d\u0435\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<h5>Anko features<\/h5>\n<p>  \u041a\u0440\u043e\u043c\u0435 DSL \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Anko \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. <br \/>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430 \u0438 \u0442\u043e, \u043a\u0430\u043a Anko \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0445 \u043c\u0435\u043d\u044f\u0442\u044c. \u042f \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0443\u0434\u0443 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u2014 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0438\u0437\u043b\u0438\u0448\u043d\u0438.  <\/p>\n<ul>\n<li>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f Toast:<br \/> \n<pre><code class=\"java\">Toast.makeText(this, &quot;Hello&quot;, Toast.LENGTH_SHORT).show() \/\/=&gt; toast(&quot;Hello&quot;) <\/code><\/pre>\n<p>  <\/li>\n<li>\u041e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 URL:<br \/> \n<pre><code class=\"java\">val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(&quot;https:\/\/www.google.com&quot;)); startActivity(browserIntent); \/\/=&gt; browse(&quot;https:\/\/www.google.com&quot;) <\/code><\/pre>\n<p>   <\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u043a \u0434\u0440\u0443\u0433\u043e\u0439 Activity:<br \/> \n<pre><code class=\"java\">val intent = Intent(this, javaClass&lt;MainActivity&gt;()) intent.putExtra(&quot;from&quot;, &quot;Peter&quot;) intent.putExtra(&quot;to&quot;, &quot;Vasya&quot;) intent.putExtra(&quot;message&quot;, &quot;hello&quot;) startActivity(intent) \/\/=&gt; startActivity&lt;MainActivity&gt;(&quot;from&quot; to &quot;Peter&quot;, &quot;to&quot; to &quot;Vasya&quot;, &quot;message&quot; to &quot;hello&quot;) <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0442\u0438\u043f\u0430 Map.   <\/li>\n<li>\u041f\u043e\u043a\u0430\u0437 \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432:<br \/> \n<pre><code class=\"java\">val dialog = AlertDialog.Builder(this)             .setTitle(&quot;Exit&quot;)             .setMessage(&quot;Do you really want exit?&quot;)             .setPositiveButton(&quot;Yes&quot;, { dialog, which -&gt;  finish() })             .setNegativeButton(&quot;No&quot;, { dialog, which -&gt; dialog.dismiss() })             .create()             .show()   \/\/=&gt;  alert(&quot;Exit&quot;, &quot;Do you really want exit?&quot;) {     positiveButton(&quot;Yes&quot;) { finish() }     negativeButton(&quot;No&quot;) { dismiss() } }.show() <\/code><\/pre>\n<p>  <\/li>\n<li>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 AsyncTask:<br \/> \n<pre><code class=\"java\">class MyTask : AsyncTask&lt;Void, Void, Void&gt;() {     override fun doInBackground(vararg params: Void?): Void? {         \/\/do some work         return null     }     override fun onPostExecute(result: Void?) {         toast(&quot;Finished&quot;)     } } val task = MyTask() task.execute()  \/\/=&gt;  async {     \/\/do some work     uiThread {         toast(&quot;Finished&quot;)     } } <\/code><\/pre>\n<p>  <\/li>\n<\/ul>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Anko \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0432\u043a\u0443\u0441\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e \u043f\u043e\u0439\u0434\u0443\u0442 \u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u0443 \u0432\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0443 \u043d\u0430 Kotlin. \u0422\u0430\u043a \u0447\u0442\u043e \u0432\u043f\u0435\u0440\u0435\u0434:  <\/p>\n<pre><code class=\"java\">compile 'org.jetbrains.anko:anko:0.6.1-19s' <\/code><\/pre>\n<p>  <\/p>\n<h4>For Android with love<\/h4>\n<p>  \u041d\u0435\u043b\u044c\u0437\u044f \u043d\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 Kotlin-\u0430 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u0442\u0430\u0440\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0438\u043c\u044f Android \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u044f\u0437\u044b\u043a \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b\u0435 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e Android-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h5>Annotation Processing<\/h5>\n<p>  \u0411\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043d\u0435\u0439 \u043d\u0430\u0437\u0430\u0434 \u0443 Android-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 DI-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 Kotlin. \u041f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0434\u0443 \u0432 \u0431\u043b\u043e\u0433\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 Kotlin-\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c <a href=\"http:\/\/blog.jetbrains.com\/kotlin\/2015\/05\/kapt-annotation-processing-for-kotlin\/\">\u0441\u0442\u0430\u0442\u044c\u044f<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/yanex\/kotlin-examples\/tree\/master\/gradle\/kotlin-dagger\">\u043f\u0440\u0438\u043c\u0435\u0440<\/a> \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Dagger. \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0435\u0449\u0435 \u0441\u044b\u0440\u043e\u0432\u0430\u0442\u0430 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f, \u043d\u043e \u043e\u0431\u0449\u0435\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0434\u0443\u0435\u0442. <br \/>  \u042f \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u043c\u043e\u0433\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u043a \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u0432\u044b\u0448\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e\u0442 \u043f\u0443\u043d\u043a\u0442 \u043f\u043e\u0439\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a \u043d\u043e\u0432\u043e\u0441\u0442\u044c.<\/p>\n<h5>Secondary constructors<\/h5>\n<p>  \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0432 Kotlin \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d primary \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440. \u042d\u0442\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0442\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u0412\u043e\u043e\u0431\u0449\u0435, \u044d\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u0430\u0432\u0434\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u0441 \u0442\u0430\u043a\u0438\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c Android-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 View \u043a\u043b\u0430\u0441\u0441\u044b. <br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e:  <\/p>\n<pre><code class=\"java\">public class MyView : LinearLayout {      public constructor(context: Context) : super(context) {     }      public constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {     }      \/\/... } <\/code><\/pre>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 secondary \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e View \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438.<\/p>\n<h5>Delegated properties<\/h5>\n<p>  \u0412\u043e\u043e\u0431\u0449\u0435, \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f Android, \u044d\u0442\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0435\u0449\u0435 \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 \u044f\u0437\u044b\u043a\u0430 M5.3, \u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u044d\u0442\u0430 \u0442\u0435\u043c\u0430 \u0435\u0449\u0435 \u043d\u0435 \u043e\u0441\u0432\u0435\u0449\u0430\u043b\u0430\u0441\u044c, \u044f \u0435\u0435 \u0437\u0430\u0442\u0440\u043e\u043d\u0443.<br \/>  \u0414\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 <i>\u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443<\/i> \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u043b\u044f \/ \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443. \u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 get \u0438 set \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f. \u0422\u0430\u043a\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<ul>\n<li>\u041b\u0435\u043d\u0438\u0432\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f;<\/li>\n<li>Observable properties \u2014 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0438 \u0440\u0435\u0430\u043a\u0446\u0438\u044f \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044f.<\/li>\n<\/ul>\n<p>  Kotlin \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 Delegation.kt \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 Delegates. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c lazy initialization:  <\/p>\n<pre><code class=\"java\">val someBigValue by Delegates.lazy {     var result = BigInteger.ONE     \/\/some hard computations     result } <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043f\u043e\u043b\u044e someBigValue \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437, \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043d\u043e \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0440\u0430\u0437 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<br \/>  <u>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/u> \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u044d\u0442\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 Singleton-\u043e\u0432, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 Kotlin \u0435\u0441\u0442\u044c <i>object declarations<\/i>.<br \/>  \u0414\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"http:\/\/kotlinlang.org\/docs\/reference\/delegated-properties.html\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<p>  \u0427\u0435\u043c \u0436\u0435 \u0442\u0430\u043a \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a Android? \u0412\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u043e\u0434\u043d\u0443 \u0438\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 Kotlin \u2014 null-safety. \u041e\u0431\u044b\u0447\u043d\u043e \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b UI \u043a\u0430\u043a \u043f\u043e\u043b\u044f Activity \/ Fragment, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"java\">private var mHelloWorldTextView : TextView = \/\/??? <\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u0432 Kotlin \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u043f\u043e\u043b\u044e \u0442\u0438\u043f\u0430 TextView \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 null. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0438\u0448\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u0442\u0430\u043a\u043e\u0435:  <\/p>\n<pre><code class=\"java\">private var mHelloWorldTextView : TextView? = null <\/code><\/pre>\n<p>  \u041d\u043e \u044d\u0442\u043e \u0432\u0435\u0434\u0435\u0442 \u043a \u0441\u0442\u0440\u0430\u0448\u043d\u044b\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c \u0441 \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 &quot;?.&quot; \u0438 &quot;!!.&quot;, \u0447\u0442\u043e \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0440\u0430\u0441\u043e\u0442\u044b \u043a\u043e\u0434\u0443:  <\/p>\n<pre><code class=\"java\">override fun onCreate(savedInstanceState: Bundle?) {     \/\/...     mHelloWorldTextView = findViewById(R.id.helloWorldTextView) as TextView?     mHelloWorldTextView?.setOnClickListener { \/*...*\/ }     val text = mHelloWorldTextView!!.getText() } <\/code><\/pre>\n<p>  \u0418 \u0437\u0434\u0435\u0441\u044c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u0441\u043f\u0435\u0448\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 notNull \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Delegates:  <\/p>\n<pre><code class=\"java\">private var mHelloWorldTextView : TextView by Delegates.notNull()  override fun onCreate(savedInstanceState: Bundle?) {     \/\/...     mHelloWorldTextView = findViewById(R.id.helloWorldTextView) as TextView     mHelloWorldTextView.setOnClickListener { \/*...*\/ }     val text = mHelloWorldTextView.getText() } <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u043b\u044e mHelloWorldText \u043f\u0435\u0440\u0435\u0434 \u0435\u0433\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c IllegalStateException. \u0412\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 Optional \u0438\u0437 Java 8.<\/p>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0443 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 Kotlin \u0434\u043b\u044f Android-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430.<br \/>  \u0418\u0437\u0443\u0447\u0430\u0439\u0442\u0435 Kotlin, \u043f\u0438\u0448\u0438\u0442\u0435 \u043d\u0430 Kotlin, \u043b\u044e\u0431\u0438\u0442\u0435 Kotlin!     \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/258683\/\"> http:\/\/habrahabr.ru\/post\/258683\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0438\u0437 \u0442\u0435\u0445, \u043a\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043f\u043e\u0434 Android, \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u043d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b \u043f\u0440\u043e Kotlin. \u041d\u0430 \u0445\u0430\u0431\u0440\u0435 \u043f\u0440\u043e \u043d\u0435\u0433\u043e \u0443\u0436\u0435 \u043f\u0438\u0441\u0430\u043b\u0438: <a href=\"http:\/\/habrahabr.ru\/company\/JetBrains\/blog\/231525\/\">\u0432\u043e\u0442 \u0441\u0442\u0430\u0442\u044c\u044f<\/a>, <a href=\"http:\/\/habrahabr.ru\/company\/e-Legion\/blog\/244999\/\">\u0432\u043e\u0442 \u0432\u0438\u0434\u0435\u043e \u0441 MBLTdev<\/a>. \u042f\u0437\u044b\u043a \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u043d\u043e\u0432\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0432\u0441\u0435 \u043d\u0435\u0442. \u042f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u043f\u043e\u0440\u0430 \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0442\u043e \u0436\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u043d\u0435 \u043e\u0441\u0432\u0435\u0449\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u0445\u0430\u0431\u0440\u0435, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-257898","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/257898","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=257898"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/257898\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=257898"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=257898"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=257898"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}