From 50e4d2df6d3b2e7ab18d73e4a2b1ec538817334c Mon Sep 17 00:00:00 2001 From: aurelioklv Date: Fri, 21 Jun 2024 06:52:34 +0700 Subject: [PATCH] update user height data type --- app/build.gradle.kts | 2 +- .../remote/api/response/ProfileResponse.kt | 2 +- .../data/remote/repository/UserRepository.kt | 35 ------------------- .../app/presentation/auth/AuthViewModel.kt | 18 ---------- .../presentation/profile/ProfileFragment.kt | 2 +- 5 files changed, 3 insertions(+), 56 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 345f5d41..26d974de 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -15,7 +15,7 @@ android { minSdk = 24 targetSdk = 34 versionCode = 1 - versionName = "1.0" + versionName = "0.1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/com/nutriomatic/app/data/remote/api/response/ProfileResponse.kt b/app/src/main/java/com/nutriomatic/app/data/remote/api/response/ProfileResponse.kt index 135ebee9..f5964531 100644 --- a/app/src/main/java/com/nutriomatic/app/data/remote/api/response/ProfileResponse.kt +++ b/app/src/main/java/com/nutriomatic/app/data/remote/api/response/ProfileResponse.kt @@ -83,5 +83,5 @@ data class User( val profpic: String, @field:SerializedName("height") - val height: Int + val height: Double ) diff --git a/app/src/main/java/com/nutriomatic/app/data/remote/repository/UserRepository.kt b/app/src/main/java/com/nutriomatic/app/data/remote/repository/UserRepository.kt index caee85b9..ad584461 100644 --- a/app/src/main/java/com/nutriomatic/app/data/remote/repository/UserRepository.kt +++ b/app/src/main/java/com/nutriomatic/app/data/remote/repository/UserRepository.kt @@ -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, diff --git a/app/src/main/java/com/nutriomatic/app/presentation/auth/AuthViewModel.kt b/app/src/main/java/com/nutriomatic/app/presentation/auth/AuthViewModel.kt index 2470558c..f5be5e6d 100644 --- a/app/src/main/java/com/nutriomatic/app/presentation/auth/AuthViewModel.kt +++ b/app/src/main/java/com/nutriomatic/app/presentation/auth/AuthViewModel.kt @@ -37,24 +37,6 @@ class AuthViewModel(private val userRepository: UserRepository) : ViewModel() { return userRepository.getTokenAndRole() } - fun saveUserModel() { - viewModelScope.launch { - userRepository.saveUserModel() - } - } - - fun getUserModel(): LiveData { - return userRepository.getUserModel() - } - -// suspend fun saveToken(token: String) { -// userRepository.saveToken(token) -// } - - fun getToken(): LiveData { - return userRepository.getToken() - } - fun logout() { viewModelScope.launch { userRepository.logout() diff --git a/app/src/main/java/com/nutriomatic/app/presentation/profile/ProfileFragment.kt b/app/src/main/java/com/nutriomatic/app/presentation/profile/ProfileFragment.kt index e5a3024e..36548782 100644 --- a/app/src/main/java/com/nutriomatic/app/presentation/profile/ProfileFragment.kt +++ b/app/src/main/java/com/nutriomatic/app/presentation/profile/ProfileFragment.kt @@ -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(