Confirm action and max warning
This commit is contained in:
parent
6e3a70a150
commit
916e2cff4e
2 changed files with 14 additions and 5 deletions
|
@ -3,8 +3,8 @@ package io.github.z3r0c00l_2k.aquadroid
|
|||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
@ -33,16 +33,21 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
|
||||
val r = sqliteHelper.addAll(dateNow, 20, totalIntake)
|
||||
Toast.makeText(this, "" + r, Toast.LENGTH_SHORT).show()
|
||||
|
||||
inTook = sqliteHelper.getIntook(dateNow)
|
||||
|
||||
setWaterLevel(inTook, totalIntake)
|
||||
|
||||
fabAdd.setOnClickListener {
|
||||
if (sqliteHelper.addIntook(dateNow) > 0) {
|
||||
inTook++
|
||||
setWaterLevel(inTook, totalIntake)
|
||||
if (inTook < totalIntake) {
|
||||
Snackbar.make(it, "Did you drank a glass of water..?", Snackbar.LENGTH_SHORT).setAction(" Yes ") {
|
||||
if (sqliteHelper.addIntook(dateNow) > 0) {
|
||||
inTook++
|
||||
setWaterLevel(inTook, totalIntake)
|
||||
}
|
||||
}.show()
|
||||
} else {
|
||||
Snackbar.make(it, "You achieved the goal", Snackbar.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,6 +59,9 @@ class MainActivity : AppCompatActivity() {
|
|||
val progress = ((inTook / totalIntake.toFloat()) * 100).toInt()
|
||||
waterLevelView.centerTitle = "" + progress + "%"
|
||||
waterLevelView.progressValue = progress
|
||||
if (inTook >= totalIntake) {
|
||||
Snackbar.make(main_activity_parent, "You achieved the goal", Snackbar.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/main_activity_parent"
|
||||
android:background="@drawable/main_bg_gradiant"
|
||||
tools:context=".MainActivity">
|
||||
<ImageButton
|
||||
|
|
Loading…
Reference in a new issue