Skip to content

Commit 6c751cf

Browse files
author
mrzhang
committed
remove findViewById in kotlin activity file
1 parent 58cf427 commit 6c751cf

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

sharecomponentkotlin/src/main/java/com/luojilab/share/kotlin/ShareMessageActivity.kt

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package com.luojilab.share.kotlin
22

33
import android.app.Activity
44
import android.os.Bundle
5-
import android.widget.TextView
65
import com.luojilab.component.componentlib.service.AutowiredService
76
import com.luojilab.componentservice.share.bean.Author
87
import com.luojilab.router.facade.annotation.Autowired
98
import com.luojilab.router.facade.annotation.RouteNode
9+
import kotlinx.android.synthetic.main.kotlin_activity_share.*
1010

1111
/**
1212
* Created by mrzhang on 2017/12/29.
@@ -22,26 +22,15 @@ class ShareMessageActivity : Activity() {
2222
@JvmField
2323
var author: Author? = null
2424

25-
var tvShareTitle: TextView? = null
26-
var tvShareBook: TextView? = null
27-
var tvAuthor: TextView? = null
28-
var tvCounty: TextView? = null
29-
3025
override fun onCreate(savedInstanceState: Bundle?) {
3126
super.onCreate(savedInstanceState)
3227
AutowiredService.Factory.getInstance().create().autowire(this)
3328
setContentView(R.layout.kotlin_activity_share)
3429

35-
tvShareTitle = findViewById<TextView>(R.id.share_title)
36-
tvShareBook = findViewById<TextView>(R.id.share_tv_tag)
37-
tvAuthor = findViewById<TextView>(R.id.share_tv_author)
38-
tvCounty = findViewById<TextView>(R.id.share_tv_county)
39-
40-
41-
tvShareTitle?.text = "Magazine"
42-
tvShareBook?.setText(magazineName)
43-
tvAuthor?.setText(author?.name ?: "zmq")
44-
tvCounty!!.setText(author?.county ?: "China")
30+
share_title.text = "Magazine"
31+
share_tv_tag.setText(magazineName)
32+
share_tv_author.setText(author?.name ?: "zmq")
33+
share_tv_county.setText(author?.county ?: "China")
4534

4635
}
4736

0 commit comments

Comments
 (0)