Removed confirmation on intake report, Adding some animations

This commit is contained in:
z3r0c00l-2k 2019-05-25 12:06:33 +05:30
parent 0fe76623f5
commit ab48de1665
3 changed files with 29 additions and 17 deletions

View file

@ -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">

View file

@ -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'
}

View file

@ -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,27 +70,28 @@ 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)
if (sqliteHelper.addIntook(dateNow, selectedOption!!) > 0) {
inTook += selectedOption!!
setWaterLevel(inTook, totalIntake)
selectedOption = null
selectedOptionName = null
opAqua.background = getDrawable(outValue.resourceId)
opCoffee.background = getDrawable(outValue.resourceId)
opTea.background = getDrawable(outValue.resourceId)
opSoftDrink.background = getDrawable(outValue.resourceId)
opJuice.background = getDrawable(outValue.resourceId)
opMilk.background = getDrawable(outValue.resourceId)
Snackbar.make(it, "Your water intake was saved...!!", Snackbar.LENGTH_SHORT).show()
}
}.show()
}
} else {
Snackbar.make(it, "You achieved the goal", Snackbar.LENGTH_SHORT).show()
Snackbar.make(it, "You already achieved the goal", Snackbar.LENGTH_SHORT).show()
}
selectedOption = null
selectedOptionName = null
opAqua.background = getDrawable(outValue.resourceId)
opCoffee.background = getDrawable(outValue.resourceId)
opTea.background = getDrawable(outValue.resourceId)
opSoftDrink.background = getDrawable(outValue.resourceId)
opJuice.background = getDrawable(outValue.resourceId)
opMilk.background = getDrawable(outValue.resourceId)
} 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()