check for input data
This commit is contained in:
parent
4b967d237c
commit
f39df8e8eb
3 changed files with 28 additions and 24 deletions
|
@ -48,18 +48,21 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
|
|||
return@setOnClickListener
|
||||
}
|
||||
profileFunction.getProfile()?.let { runningProfile ->
|
||||
val profile = defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())
|
||||
ProfileViewerDialog().also { pvd ->
|
||||
pvd.arguments = Bundle().also {
|
||||
it.putLong("time", DateUtil.now())
|
||||
it.putInt("mode", ProfileViewerDialog.Mode.PROFILE_COMPARE.ordinal)
|
||||
it.putString("customProfile", runningProfile.data.toString())
|
||||
it.putString("customProfile2", profile.data.toString())
|
||||
it.putString("customProfileUnits", profile.units)
|
||||
it.putString("customProfileName", "Age: $age TDD: $tdd Weight: $weight")
|
||||
}
|
||||
}.show(supportFragmentManager, "ProfileViewDialog")
|
||||
defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())?.let { profile ->
|
||||
ProfileViewerDialog().also { pvd ->
|
||||
pvd.arguments = Bundle().also {
|
||||
it.putLong("time", DateUtil.now())
|
||||
it.putInt("mode", ProfileViewerDialog.Mode.PROFILE_COMPARE.ordinal)
|
||||
it.putString("customProfile", runningProfile.data.toString())
|
||||
it.putString("customProfile2", profile.data.toString())
|
||||
it.putString("customProfileUnits", profile.units)
|
||||
it.putString("customProfileName", "Age: $age TDD: $tdd Weight: $weight")
|
||||
}
|
||||
}.show(supportFragmentManager, "ProfileViewDialog")
|
||||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
ToastUtils.showToastInUiThread(this, R.string.invalidinput)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,17 +63,18 @@ class SurveyActivity : NoSplashAppCompatActivity() {
|
|||
return@setOnClickListener
|
||||
}
|
||||
profileFunction.getProfile()?.let { runningProfile ->
|
||||
val profile = defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())
|
||||
ProfileViewerDialog().also { pvd ->
|
||||
pvd.arguments = Bundle().also {
|
||||
it.putLong("time", DateUtil.now())
|
||||
it.putInt("mode", ProfileViewerDialog.Mode.PROFILE_COMPARE.ordinal)
|
||||
it.putString("customProfile", runningProfile.data.toString())
|
||||
it.putString("customProfile2", profile.data.toString())
|
||||
it.putString("customProfileUnits", profile.units)
|
||||
it.putString("customProfileName", "Age: $age TDD: $tdd Weight: $weight")
|
||||
}
|
||||
}.show(supportFragmentManager, "ProfileViewDialog")
|
||||
defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())?.let { profile ->
|
||||
ProfileViewerDialog().also { pvd ->
|
||||
pvd.arguments = Bundle().also {
|
||||
it.putLong("time", DateUtil.now())
|
||||
it.putInt("mode", ProfileViewerDialog.Mode.PROFILE_COMPARE.ordinal)
|
||||
it.putString("customProfile", runningProfile.data.toString())
|
||||
it.putString("customProfile2", profile.data.toString())
|
||||
it.putString("customProfileUnits", profile.units)
|
||||
it.putString("customProfileName", "Age: $age TDD: $tdd Weight: $weight")
|
||||
}
|
||||
}.show(supportFragmentManager, "ProfileViewDialog")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class DefaultProfile @Inject constructor(val injector: HasAndroidInjector) {
|
|||
var twelveToSeventeen: 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()
|
||||
if (age >= 1 && age < 6) {
|
||||
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)
|
||||
profile.put("sens", singleValueArray(isf, arrayOf(0.2, 0.0, 0.2, 0.2, 0.0, 0.2, 0.2)))
|
||||
} else if (age >= 18) {
|
||||
|
||||
return null
|
||||
}
|
||||
profile.put("dia", 5.0)
|
||||
profile.put("carbs_hr", 20) // not used
|
||||
|
|
Loading…
Reference in a new issue