From fc28482b6fabeb3ce4457ff5b67e74669edca76b Mon Sep 17 00:00:00 2001 From: Diraj H S Date: Fri, 14 Jun 2024 19:14:55 +0530 Subject: [PATCH] Updated dependencies and fixed related issues Signed-off-by: Diraj H S --- README.md | 4 ++++ app/build.gradle | 18 +++++++-------- .../android/marsrealestate/BindingAdapters.kt | 2 +- .../marsrealestate/detail/DetailViewModel.kt | 6 ++--- build.gradle | 23 ++++++++++--------- gradle/wrapper/gradle-wrapper.properties | 2 +- 6 files changed, 29 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index bdf311c3..5b588249 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,10 @@ Access all branches from this tab. The branches are also accessible from the drop-down in the "Code" tab. +## Requirements + +1. Android Studio (Jellyfish or above) +2. JDK 21 with `JAVA_HOME` environment variable set. If you don't have JDK 21 installed or `JAVA_HOME` is not set, consider using a tool like `sdkman` to simplify the process. Refer to the sdkman documentation for installation instructions: [sdkman installation](https://sdkman.io/install) ## Working with the Course Code diff --git a/app/build.gradle b/app/build.gradle index f03e075f..ccce9ef3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,19 +17,19 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: "androidx.navigation.safeargs" +apply plugin: 'kotlin-parcelize' android { - compileSdkVersion 31 + compileSdk 34 buildFeatures { dataBinding true } defaultConfig { applicationId "com.example.android.marsrealestate" - minSdkVersion 19 - targetSdkVersion 31 + minSdkVersion 21 + targetSdkVersion 34 versionCode 1 versionName "1.0" multiDexEnabled true @@ -40,13 +40,11 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } + namespace = "com.example.android.marsrealestate" - kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() + compileOptions { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } } diff --git a/app/src/main/java/com/example/android/marsrealestate/BindingAdapters.kt b/app/src/main/java/com/example/android/marsrealestate/BindingAdapters.kt index 4dac1d4d..21b1a944 100644 --- a/app/src/main/java/com/example/android/marsrealestate/BindingAdapters.kt +++ b/app/src/main/java/com/example/android/marsrealestate/BindingAdapters.kt @@ -67,7 +67,7 @@ fun bindStatus(statusImageView: ImageView, status: MarsApiStatus?) { statusImageView.visibility = View.VISIBLE statusImageView.setImageResource(R.drawable.loading_animation) } - MarsApiStatus.ERROR -> { + MarsApiStatus.ERROR, null -> { statusImageView.visibility = View.VISIBLE statusImageView.setImageResource(R.drawable.ic_connection_error) } diff --git a/app/src/main/java/com/example/android/marsrealestate/detail/DetailViewModel.kt b/app/src/main/java/com/example/android/marsrealestate/detail/DetailViewModel.kt index de5bc19b..aae70ff8 100644 --- a/app/src/main/java/com/example/android/marsrealestate/detail/DetailViewModel.kt +++ b/app/src/main/java/com/example/android/marsrealestate/detail/DetailViewModel.kt @@ -20,8 +20,8 @@ import android.app.Application import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.Transformations import androidx.lifecycle.ViewModel +import androidx.lifecycle.map import com.example.android.marsrealestate.R import com.example.android.marsrealestate.network.MarsProperty @@ -43,7 +43,7 @@ class DetailViewModel(marsProperty: MarsProperty, app: Application) : AndroidVie // The displayPropertyPrice formatted Transformation Map LiveData, which displays the sale // or rental price. - val displayPropertyPrice = Transformations.map(selectedProperty) { + val displayPropertyPrice = selectedProperty.map() { app.applicationContext.getString( when (it.isRental) { true -> R.string.display_price_monthly_rental @@ -53,7 +53,7 @@ class DetailViewModel(marsProperty: MarsProperty, app: Application) : AndroidVie // The displayPropertyType formatted Transformation Map LiveData, which displays the // "For Rent/Sale" String - val displayPropertyType = Transformations.map(selectedProperty) { + val displayPropertyType = selectedProperty.map() { app.applicationContext.getString(R.string.display_type, app.applicationContext.getString( when(it.isRental) { diff --git a/build.gradle b/build.gradle index 2867511b..13ec9df3 100644 --- a/build.gradle +++ b/build.gradle @@ -6,18 +6,19 @@ buildscript { // Versions for all the dependencies we plan to use. It's particularly useful for kotlin and // navigation where the versions of the plugin needs to be the same as the version of the // library defined in the app Gradle file - version_core = "1.3.1" - version_constraint_layout = "2.0.0-rc1" - version_glide = "4.8.0" - version_gradle = '7.1.0' - version_kotlin = '1.4.10' - version_kotlin_coroutines = "1.3.7" - version_lifecycle = '2.4.1' - version_moshi = "1.13.0" - version_navigation = '2.4.1' + version_android_gradle_plugin = '8.4.2' + version_core = "1.13.1" + version_constraint_layout = "2.1.4" + version_glide = "4.16.0" + version_gradle = '8.4.2' + version_kotlin = '1.9.24' + version_kotlin_coroutines = "1.8.1" + version_lifecycle = '2.8.2' + version_moshi = "1.15.1" + version_navigation = '2.7.7' version_retrofit = "2.9.0" version_retrofit_coroutines_adapter = "0.9.2" - version_recyclerview = "1.2.0-alpha05" + version_recyclerview = "1.3.2" } repositories { @@ -25,7 +26,7 @@ buildscript { google() } dependencies { - classpath "com.android.tools.build:gradle:$version_gradle" + classpath "com.android.tools.build:gradle:$version_android_gradle_plugin" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$version_kotlin" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$version_navigation" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 80f30ba6..b2b9efd9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -20,4 +20,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME android.databinding.enableV2=true zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip