Changed some function and add new function to demo

This commit is contained in:
2022-03-29 13:49:07 +08:00
parent ee9ea8b2d5
commit 31410eb6e1
10 changed files with 236 additions and 118 deletions

View File

@@ -41,6 +41,9 @@ android {
kotlinOptions {
jvmTarget = '11'
}
buildFeatures {
viewBinding true
}
}
dependencies {

View File

@@ -30,28 +30,31 @@
package com.highcapable.yukihookapi.demo_app.ui
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.highcapable.yukihookapi.demo_app.R
import com.highcapable.yukihookapi.demo_app.databinding.ActivityMainBinding
import com.highcapable.yukihookapi.demo_app.utils.Main
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
findViewById<TextView>(R.id.app_demo_first_text).text = getFirstText()
findViewById<TextView>(R.id.app_demo_second_text).text = secondText
findViewById<TextView>(R.id.app_demo_third_text).text = Main("Feel real").getString()
findViewById<TextView>(R.id.app_demo_fourth_text).text = getRegularText("Have fun day")
findViewById<TextView>(R.id.app_demo_fifth_text).text = getDataText()
findViewById<Button>(R.id.app_demo_button).setOnClickListener { toast() }
ActivityMainBinding.inflate(layoutInflater).apply {
setContentView(root)
appDemoFirstText.text = getFirstText()
appDemoSecondText.text = secondText
appDemoThirdText.text = Main(string = "Feel real").getString()
appDemoFourthText.text = getRegularText(string = "Have fun day")
appDemoFifthText.text = getDataText()
appDemoSixthText.text = getArray(arrayOf("apple", "banana")).let { "${it[0]}, ${it[1]}" }
appDemoButton.setOnClickListener { toast() }
}
}
private val secondText = "This is a miracle"
private fun getArray(array: Array<String>) = array
private fun getFirstText() = "Hello World!"
private fun getRegularText(string: String) = string

View File

@@ -47,6 +47,14 @@
android:text="sample"
android:textSize="20sp" />
<TextView
android:id="@+id/app_demo_sixth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:text="sample"
android:textSize="20sp" />
<Button
android:id="@+id/app_demo_button"
android:layout_width="wrap_content"