Files
FitnessDroid/app/src/main/java/eu/brassepc/fitnessdroid/data/Bmr.kt
claude 06b2f0ec86
All checks were successful
release / build-release (push) Successful in 5m54s
Etapp 1: kroppsdata synkas mot servern + BMR + dagens kcal-mätare på Hem
- Profile/myProfile med heightCm/birthYear/sex (fallback mot äldre server),
  updateProfile-mutation i GymApi
- Kroppsdata sparas lokalt och synkas: serverns värden vinner, lokala pushas
  upp om servern är tom (migrerar vågens lokala data)
- Mifflin–St Jeor-BMR (data/Bmr.kt)
- Hemskärm: Dagens kalorier-kort — aktivt loggat (dagens pass), telefonen
  (platshållare för etapp 5) och passivt (BMR-andel av dygnet, tickar per
  minut). Uppmaning om kroppsdata saknas.
- Version 0.5.0

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C2GA94E1f3cmrvdQLQhYdg
2026-08-23 17:20:39 +02:00

21 lines
635 B
Kotlin
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package eu.brassepc.fitnessdroid.data
import java.time.LocalDate
/**
* Basalmetabolism (kcal/dygn) enligt MifflinSt Jeor:
* 10·vikt + 6.25·längd 5·ålder + 5 (man) / 161 (kvinna).
* null om något av underlagen saknas.
*/
fun bmrKcalPerDay(
weightKg: Double?,
heightCm: Double?,
birthYear: Int?,
isFemale: Boolean?,
): Double? {
if (weightKg == null || heightCm == null || birthYear == null || isFemale == null) return null
val age = (LocalDate.now().year - birthYear).coerceIn(0, 120)
val k = if (isFemale) -161.0 else 5.0
return 10.0 * weightKg + 6.25 * heightCm - 5.0 * age + k
}