Skip to content

Commit

Permalink
convert to viewBinding
Browse files Browse the repository at this point in the history
  • Loading branch information
yechao committed Oct 16, 2021
1 parent 61eede4 commit 8ef6dbf
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 56 deletions.
18 changes: 1 addition & 17 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

10 changes: 7 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 30

Expand All @@ -21,18 +21,22 @@ android {
}
}

buildFeatures {
viewBinding = true
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

implementation "com.google.android.material:material:1.2.1"
implementation "com.google.android.material:material:1.3.0"

implementation project(':yutils')
implementation project(':yutilskt')
Expand Down
24 changes: 13 additions & 11 deletions app/src/main/java/com/yechaoa/app/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
package com.yechaoa.app

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import android.widget.TextView
import com.google.android.material.snackbar.Snackbar
import androidx.appcompat.app.AppCompatActivity
import com.yechaoa.app.databinding.ActivityMainBinding
import com.yechaoa.yutilskt.*
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity() {

private lateinit var mBinding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
mBinding = ActivityMainBinding.inflate(layoutInflater)
setContentView(mBinding.root)

findViewById<TextView>(R.id.text_view).setOnClickListener {
YUtils.showLoading(this, "加载中")
}

btn_log.setOnClickListener {
mBinding.btnLog.setOnClickListener {
LogUtil.d(getString(R.string.large_text))
}

Expand All @@ -29,22 +31,22 @@ class MainActivity : AppCompatActivity() {
set.add("-----" + array[i])
}

button.setOnClickListener {
mBinding.button.setOnClickListener {
SpUtil.setStringSet("testStringSet", set)
//SpUtil.getBoolean("111",true)
}

button2.setOnClickListener {
mBinding.button2.setOnClickListener {
val stringSet = SpUtil.getStringSet("testStringSet")
LogUtil.i(stringSet.toString())
}

showLoading.setOnClickListener {
mBinding.showLoading.setOnClickListener {
YUtils.showLoading(this, "test")
LogUtil.i("" + YUtils.loadingIsShowing())
}

hideLoading.setOnClickListener {
mBinding.hideLoading.setOnClickListener {
ToastUtil.show("取消loading")
YUtils.hideLoading()
LogUtil.i("" + YUtils.loadingIsShowing())
Expand All @@ -54,12 +56,12 @@ class MainActivity : AppCompatActivity() {
// ActivityUtil.start(MainActivity::class.java)
// ActivityUtil.finish(this)

btn_display.setOnClickListener {
mBinding.btnDisplay.setOnClickListener {
LogUtil.i("" + DisplayUtil.getStatusBarHeight() + "---" + DisplayUtil.getScreenHeight())
LogUtil.i("" + DisplayUtil.getActionBarHeight() + "---" + DisplayUtil.getNavBarHeight())
}

btn_sim.setOnClickListener {
mBinding.btnSim.setOnClickListener {
ToastUtil.show(if (YUtils.hasSim()) "有sim卡" else "无sim卡")
}
}
Expand Down

0 comments on commit 8ef6dbf

Please sign in to comment.