Skip to content

Commit

Permalink
improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
ruirigel committed May 21, 2024
1 parent c769c18 commit 646d878
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
8 changes: 8 additions & 0 deletions .idea/deploymentTargetSelector.xml

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

4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId = "com.example.myapplication"
minSdk = 26
targetSdk = 34
versionCode = 20240518
versionName = "v20240518"
versionCode = 20240521
versionName = "v20240521"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
25 changes: 20 additions & 5 deletions app/src/main/java/com/example/myapplication/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import android.os.VibrationEffect
import android.os.Vibrator
import android.provider.Settings
import android.telephony.TelephonyManager
import android.text.Html
import android.text.InputFilter
import android.text.InputType
import android.util.Log
Expand Down Expand Up @@ -416,7 +417,7 @@ class MainActivity : AppCompatActivity() {
buttons.setBackgroundColor(Color.parseColor("#3F51B4"))
buttons.isEnabled = true
buttons.isClickable = true
buttons.text = null
buttons.text = " "

buttons.animate()
.translationY(0f)
Expand Down Expand Up @@ -477,7 +478,7 @@ class MainActivity : AppCompatActivity() {
numberstar = (minStarBubble..maxStarBubble).random()
val buttonss = findViewById<Button>(buttonIds[numberstar])
buttonss.setBackgroundColor(Color.YELLOW)
buttonss.text = ""
buttonss.text = Html.fromHtml("<font color='#009688'>★</font>")
buttonss.textSize = 44f
buttonss.setTextColor(Color.parseColor("#2B2D30"))
buttonss.startAnimation(AnimationUtils.loadAnimation(this, R.anim.shake))
Expand Down Expand Up @@ -619,7 +620,13 @@ class MainActivity : AppCompatActivity() {
if (scorevalue.isNotEmpty()) {
val numa: Int = scorevalue.toInt()
val numb: Int = arg1.toInt()
val result = numa + numb

val result: Int = if (numb == 0) {
numa - 10
} else {
numa + numb
}

val finalresult = result.toString()
myRef.child("score").setValue(finalresult)

Expand All @@ -628,7 +635,12 @@ class MainActivity : AppCompatActivity() {
val scorevaluenow: String = textView1.text.toString()
val numanow: Int = scorevaluenow.toInt()
val numbnow: Int = arg1.toInt()
val resultnow = numbnow + numanow

val resultnow: Int = if (numb == 0) {
numanow - 10
} else {
numanow + numbnow
}
textView1.text = resultnow.toString()

//delayscore(numanow, resultnow)
Expand Down Expand Up @@ -1000,6 +1012,10 @@ class MainActivity : AppCompatActivity() {

private fun checkButtonColor(arg1: CharSequence) {
when (arg1) {
" " -> {
savescore("0")
}

"+1" -> {
savescore("1")
}
Expand Down Expand Up @@ -1069,6 +1085,5 @@ class MainActivity : AppCompatActivity() {
private const val TAG = "AnonymousAuth"
}


}

6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@

<ImageView
android:id="@+id/imageView2"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginTop="6dp"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_marginTop="3dp"
app:layout_constraintEnd_toStartOf="@+id/textView1"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/circle"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.4.0" apply false
id("com.android.application") version "8.4.1" apply false
id("org.jetbrains.kotlin.android") version "1.9.22" apply false
id("com.google.gms.google-services") version "4.4.1" apply false
}

0 comments on commit 646d878

Please sign in to comment.