Skip to content

Commit

Permalink
Migrate from kotlin.synthetic to ViewBinding
Browse files Browse the repository at this point in the history
  • Loading branch information
Caio Costa committed Nov 18, 2020
1 parent 9873f00 commit 61f913b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
8 changes: 5 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
compileSdkVersion 30
defaultConfig {
applicationId "br.com.caiodev.newmaterialdesigntest"
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
buildFeatures {
viewBinding true
}
buildTypes {
release {
minifyEnabled true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@ package br.com.caiodev.newmaterialdesigntest
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import br.com.caiodev.newmaterialdesigntest.databinding.ActivityMainBinding
import com.google.android.material.chip.Chip
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity(R.layout.activity_main) {
class MainActivity : AppCompatActivity() {

private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setChipListener(firstChip)
setChipListener(chip)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
setupView()
}

private fun setupView() {
setChipListener(binding.firstChip)
setChipListener(binding.chip)

binding.chipList.apply {
setHasFixedSize(true)
}
}

private fun setChipListener(chip: Chip) {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@

</HorizontalScrollView>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/chipList"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />

</androidx.constraintlayout.widget.ConstraintLayout>

</ScrollView>

0 comments on commit 61f913b

Please sign in to comment.