Removed confirmation on intake report, Adding some animations
This commit is contained in:
parent
0fe76623f5
commit
ab48de1665
3 changed files with 29 additions and 17 deletions
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -41,4 +41,6 @@ dependencies {
|
|||
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'com.params.progressview:step-progress:1.0.2'
|
||||
implementation 'com.daimajia.easing:library:2.0@aar'
|
||||
implementation 'com.daimajia.androidanimations:library:2.3@aar'
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import android.content.SharedPreferences
|
|||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.daimajia.androidanimations.library.Techniques
|
||||
import com.daimajia.androidanimations.library.YoYo
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import io.github.z3r0c00l_2k.aquadroid.fragments.BottomSheetFragment
|
||||
import io.github.z3r0c00l_2k.aquadroid.helpers.AlarmHelper
|
||||
|
@ -68,12 +70,16 @@ class MainActivity : AppCompatActivity() {
|
|||
fabAdd.setOnClickListener {
|
||||
if (selectedOption != null && selectedOptionName != null) {
|
||||
if ((inTook * 100 / totalIntake) <= 140) {
|
||||
snackbar = Snackbar.make(it, "Did you drank $selectedOptionName..?", Snackbar.LENGTH_SHORT)
|
||||
snackbar!!.setAction("\t\t\tYes\t\t\t") {
|
||||
if (sqliteHelper.addIntook(dateNow, selectedOption!!) > 0) {
|
||||
inTook += selectedOption!!
|
||||
setWaterLevel(inTook, totalIntake)
|
||||
|
||||
Snackbar.make(it, "Your water intake was saved...!!", Snackbar.LENGTH_SHORT).show()
|
||||
|
||||
}
|
||||
} else {
|
||||
Snackbar.make(it, "You already achieved the goal", Snackbar.LENGTH_SHORT).show()
|
||||
}
|
||||
selectedOption = null
|
||||
selectedOptionName = null
|
||||
opAqua.background = getDrawable(outValue.resourceId)
|
||||
|
@ -82,13 +88,10 @@ class MainActivity : AppCompatActivity() {
|
|||
opSoftDrink.background = getDrawable(outValue.resourceId)
|
||||
opJuice.background = getDrawable(outValue.resourceId)
|
||||
opMilk.background = getDrawable(outValue.resourceId)
|
||||
|
||||
}
|
||||
}.show()
|
||||
} else {
|
||||
Snackbar.make(it, "You achieved the goal", Snackbar.LENGTH_SHORT).show()
|
||||
}
|
||||
} else {
|
||||
YoYo.with(Techniques.Shake)
|
||||
.duration(700)
|
||||
.playOn(cardView)
|
||||
Snackbar.make(it, "Please select an option", Snackbar.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
@ -205,9 +208,16 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
private fun setWaterLevel(inTook: Int, totalIntake: Int) {
|
||||
|
||||
YoYo.with(Techniques.SlideInDown)
|
||||
.duration(500)
|
||||
.playOn(tvIntook)
|
||||
tvIntook.text = "$inTook"
|
||||
tvTotalIntake.text = "/$totalIntake ml"
|
||||
val progress = ((inTook / totalIntake.toFloat()) * 100).toInt()
|
||||
YoYo.with(Techniques.Pulse)
|
||||
.duration(500)
|
||||
.playOn(intakeProgress)
|
||||
intakeProgress.currentProgress = progress
|
||||
if ((inTook * 100 / totalIntake) > 140) {
|
||||
Snackbar.make(main_activity_parent, "You achieved the goal", Snackbar.LENGTH_SHORT).show()
|
||||
|
|
Loading…
Reference in a new issue