From b1c0612bd8a06c30ddee7e20fa1a7e376b3e0ef1 Mon Sep 17 00:00:00 2001 From: Amr Hossam Date: Mon, 24 Jun 2024 01:35:36 +0300 Subject: [PATCH] Populate nutrition programs correctly --- .../main/java/com/modarb/android/network/ApiService.kt | 2 +- .../nutrition/activities/AboutNutritionPlanActivity.kt | 10 +++++++--- .../ui/nutrition/adapters/NutritionViewPagerAdapter.kt | 4 +++- .../main/res/layout/item_customworkout_template.xml | 2 +- app/src/main/res/layout/item_nutrition_program.xml | 3 +++ 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/modarb/android/network/ApiService.kt b/app/src/main/java/com/modarb/android/network/ApiService.kt index b726d1a..35d8585 100644 --- a/app/src/main/java/com/modarb/android/network/ApiService.kt +++ b/app/src/main/java/com/modarb/android/network/ApiService.kt @@ -127,7 +127,7 @@ interface ApiService { @Header("Authorization") token: String, ): Response - @GET("api/v1/user/mealPlans") + @GET("api/v1/user/mealPlans?limit=200") suspend fun getAllMealsPlan( @Header("Authorization") token: String, ): Response diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/nutrition/activities/AboutNutritionPlanActivity.kt b/app/src/main/java/com/modarb/android/ui/home/ui/nutrition/activities/AboutNutritionPlanActivity.kt index 3dde5be..c2b211f 100644 --- a/app/src/main/java/com/modarb/android/ui/home/ui/nutrition/activities/AboutNutritionPlanActivity.kt +++ b/app/src/main/java/com/modarb/android/ui/home/ui/nutrition/activities/AboutNutritionPlanActivity.kt @@ -109,7 +109,8 @@ class AboutNutritionPlanActivity : AppCompatActivity() { } } - if (keyFeature.isNotEmpty()) binding.desKeyFeaturesTextView1.text = keyFeature + if (keyFeature != null && keyFeature.isNotEmpty()) binding.desKeyFeaturesTextView1.text = + keyFeature else binding.keyFeaturesTextView.visibility = View.GONE if (NutritionHelper.selectedMyProgram.your_journey != null) binding.desYourJourneyTextView.text = NutritionHelper.selectedMyProgram.your_journey @@ -130,8 +131,11 @@ class AboutNutritionPlanActivity : AppCompatActivity() { } } - if (keyFeature.isNotEmpty()) binding.desKeyFeaturesTextView1.text = keyFeature - if (NutritionHelper.selectedProgram.your_journey.isNotEmpty()) binding.desYourJourneyTextView.text = + if (keyFeature != null && keyFeature.isNotEmpty()) binding.desKeyFeaturesTextView1.text = + keyFeature + else binding.keyFeaturesTextView.visibility = View.GONE + if (NutritionHelper.selectedProgram.your_journey != null) binding.desYourJourneyTextView.text = NutritionHelper.selectedProgram.your_journey + else binding.yourJourneyTextView.visibility = View.GONE } } \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/nutrition/adapters/NutritionViewPagerAdapter.kt b/app/src/main/java/com/modarb/android/ui/home/ui/nutrition/adapters/NutritionViewPagerAdapter.kt index c9c61dd..098f0d4 100644 --- a/app/src/main/java/com/modarb/android/ui/home/ui/nutrition/adapters/NutritionViewPagerAdapter.kt +++ b/app/src/main/java/com/modarb/android/ui/home/ui/nutrition/adapters/NutritionViewPagerAdapter.kt @@ -237,8 +237,10 @@ class NutritionViewPagerAdapter( private fun initPlansPrograms() { binding.recycleView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) + + val data = allMealsResponse.data.asReversed() val programsAdapter = - NutritionProgramsAdapter(allMealsResponse.data, this@NutritionViewPagerAdapter) + NutritionProgramsAdapter(data, this@NutritionViewPagerAdapter) binding.recycleView.adapter = programsAdapter } diff --git a/app/src/main/res/layout/item_customworkout_template.xml b/app/src/main/res/layout/item_customworkout_template.xml index a509e6d..fcb2cf1 100644 --- a/app/src/main/res/layout/item_customworkout_template.xml +++ b/app/src/main/res/layout/item_customworkout_template.xml @@ -104,7 +104,7 @@ android:layout_height="wrap_content" android:layout_margin="4dp" android:textColor="@color/white_700" - tools:text="50 kg" /> + android:text="0 kg" /> diff --git a/app/src/main/res/layout/item_nutrition_program.xml b/app/src/main/res/layout/item_nutrition_program.xml index 3b87756..50de036 100644 --- a/app/src/main/res/layout/item_nutrition_program.xml +++ b/app/src/main/res/layout/item_nutrition_program.xml @@ -38,6 +38,7 @@ android:layout_marginTop="16dp" android:layout_marginEnd="32dp" android:layout_marginBottom="16dp" + android:maxLines="1" android:textColor="@color/white" android:textSize="20sp" app:layout_constraintBottom_toBottomOf="@+id/image" @@ -45,6 +46,7 @@ app:layout_constraintHorizontal_bias="0.14" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="@+id/image" + app:layout_constraintVertical_bias="0.39999998" tools:text="Plan Name" />