Skip to content

Commit

Permalink
update user height data type
Browse files Browse the repository at this point in the history
  • Loading branch information
aurelioklv committed Jun 20, 2024
1 parent cf43cf9 commit 50e4d2d
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 56 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
versionName = "0.1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ data class User(
val profpic: String,

@field:SerializedName("height")
val height: Int
val height: Double
)
Original file line number Diff line number Diff line change
Expand Up @@ -83,41 +83,6 @@ class UserRepository private constructor(
}
}

suspend fun saveUserModel() {
try {
val response = apiService.getProfile()
with(response.user) {
userPreference.saveUserModel(
UserModel(
id = id,
name = name,
email = email,
gender = gender,
role = role,
telp = telp,
profpic = profpic,
birthdate = birthdate,
place = place,
height = height,
weight = weight,
weightGoal = weightGoal,
hgId = hgId,
hgType = hgType,
hgDesc = hgDesc,
alId = alId,
alType = alType,
alDesc = alDesc,
alValue = alValue
)
)
}
} catch (e: HttpException) {
val jsonString = e.response()?.errorBody()?.string()
val errorBody = Gson().fromJson(jsonString, ErrorResponse::class.java)
val errorMessage = errorBody.message
}
}

suspend fun updateProfile(
name: RequestBody,
email: RequestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,6 @@ class AuthViewModel(private val userRepository: UserRepository) : ViewModel() {
return userRepository.getTokenAndRole()
}

fun saveUserModel() {
viewModelScope.launch {
userRepository.saveUserModel()
}
}

fun getUserModel(): LiveData<UserModel> {
return userRepository.getUserModel()
}

// suspend fun saveToken(token: String) {
// userRepository.saveToken(token)
// }

fun getToken(): LiveData<String?> {
return userRepository.getToken()
}

fun logout() {
viewModelScope.launch {
userRepository.logout()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class ProfileFragment : Fragment() {
val genderName =
LocalData.getGenderNameByCode(requireContext(), this.gender)
binding.txtGenderInput.setText(genderName, false)
binding.txtHeightInput.setText(this.height.toString())
binding.txtHeightInput.setText(this.height.times(100).toInt().toString())
binding.txtWeightInput.setText(this.weight.toString())
binding.txtWeightGoalInput.setText(this.weightGoal.toString())
val alName = LocalData.getActivityLevelNameByCode(
Expand Down

0 comments on commit 50e4d2d

Please sign in to comment.