check for input data
This commit is contained in:
parent
4b967d237c
commit
f39df8e8eb
3 changed files with 28 additions and 24 deletions
|
@ -48,7 +48,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
profileFunction.getProfile()?.let { runningProfile ->
|
profileFunction.getProfile()?.let { runningProfile ->
|
||||||
val profile = defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())
|
defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())?.let { profile ->
|
||||||
ProfileViewerDialog().also { pvd ->
|
ProfileViewerDialog().also { pvd ->
|
||||||
pvd.arguments = Bundle().also {
|
pvd.arguments = Bundle().also {
|
||||||
it.putLong("time", DateUtil.now())
|
it.putLong("time", DateUtil.now())
|
||||||
|
@ -59,8 +59,11 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
|
||||||
it.putString("customProfileName", "Age: $age TDD: $tdd Weight: $weight")
|
it.putString("customProfileName", "Age: $age TDD: $tdd Weight: $weight")
|
||||||
}
|
}
|
||||||
}.show(supportFragmentManager, "ProfileViewDialog")
|
}.show(supportFragmentManager, "ProfileViewDialog")
|
||||||
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ToastUtils.showToastInUiThread(this, R.string.invalidinput)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ class SurveyActivity : NoSplashAppCompatActivity() {
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
profileFunction.getProfile()?.let { runningProfile ->
|
profileFunction.getProfile()?.let { runningProfile ->
|
||||||
val profile = defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())
|
defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())?.let { profile ->
|
||||||
ProfileViewerDialog().also { pvd ->
|
ProfileViewerDialog().also { pvd ->
|
||||||
pvd.arguments = Bundle().also {
|
pvd.arguments = Bundle().also {
|
||||||
it.putLong("time", DateUtil.now())
|
it.putLong("time", DateUtil.now())
|
||||||
|
@ -76,6 +76,7 @@ class SurveyActivity : NoSplashAppCompatActivity() {
|
||||||
}.show(supportFragmentManager, "ProfileViewDialog")
|
}.show(supportFragmentManager, "ProfileViewDialog")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
survey_submit.setOnClickListener {
|
survey_submit.setOnClickListener {
|
||||||
val r = FirebaseRecord()
|
val r = FirebaseRecord()
|
||||||
|
|
|
@ -17,7 +17,7 @@ class DefaultProfile @Inject constructor(val injector: HasAndroidInjector) {
|
||||||
var twelveToSeventeen: TreeMap<Double, Array<Double>> = TreeMap()
|
var twelveToSeventeen: TreeMap<Double, Array<Double>> = TreeMap()
|
||||||
var eighteenToTwentyfor: TreeMap<Double, Array<Double>> = TreeMap()
|
var eighteenToTwentyfor: TreeMap<Double, Array<Double>> = TreeMap()
|
||||||
|
|
||||||
fun profile(age: Double, tdd: Double, weight: Double, units: String): Profile {
|
fun profile(age: Double, tdd: Double, weight: Double, units: String): Profile? {
|
||||||
val profile = JSONObject()
|
val profile = JSONObject()
|
||||||
if (age >= 1 && age < 6) {
|
if (age >= 1 && age < 6) {
|
||||||
val _tdd = if (tdd == 0.0) 0.6 * weight else tdd
|
val _tdd = if (tdd == 0.0) 0.6 * weight else tdd
|
||||||
|
@ -41,7 +41,7 @@ class DefaultProfile @Inject constructor(val injector: HasAndroidInjector) {
|
||||||
val isf = Round.roundTo(100.0 / _tdd, 0.1)
|
val isf = Round.roundTo(100.0 / _tdd, 0.1)
|
||||||
profile.put("sens", singleValueArray(isf, arrayOf(0.2, 0.0, 0.2, 0.2, 0.0, 0.2, 0.2)))
|
profile.put("sens", singleValueArray(isf, arrayOf(0.2, 0.0, 0.2, 0.2, 0.0, 0.2, 0.2)))
|
||||||
} else if (age >= 18) {
|
} else if (age >= 18) {
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
profile.put("dia", 5.0)
|
profile.put("dia", 5.0)
|
||||||
profile.put("carbs_hr", 20) // not used
|
profile.put("carbs_hr", 20) // not used
|
||||||
|
|
Loading…
Reference in a new issue