From dec57d91a0c15d526f68c54d2bed3d65409260dc Mon Sep 17 00:00:00 2001 From: John De la cruz Date: Mon, 26 Dec 2022 13:30:38 -0500 Subject: [PATCH] Update dependencies --- .gitignore | 15 ++++++++++ .idea/.gitignore | 3 ++ advanced/end/.idea/.gitignore | 0 advanced/end/app/build.gradle | 7 ++++- advanced/end/app/src/main/AndroidManifest.xml | 3 +- .../codelabs/paging/ui/ReposAdapter.kt | 1 + .../paging/ui/SearchRepositoriesActivity.kt | 9 ++++-- .../paging/ui/SearchRepositoriesViewModel.kt | 8 ++++-- .../codelabs/paging/ui/ViewModelFactory.kt | 2 +- advanced/end/build.gradle | 28 +++++++++---------- advanced/end/gradle.properties | 15 ++++++++++ .../gradle/wrapper/gradle-wrapper.properties | 2 +- advanced/end/local.properties | 8 ++++++ advanced/start/.idea/.gitignore | 3 ++ advanced/start/app/build.gradle | 1 + .../start/app/src/main/AndroidManifest.xml | 3 +- .../codelabs/paging/ui/ViewModelFactory.kt | 2 +- advanced/start/build.gradle | 28 +++++++++---------- .../gradle/wrapper/gradle-wrapper.properties | 2 +- advanced/start/local.properties | 8 ++++++ basic/end/app/build.gradle | 1 + basic/end/app/src/main/AndroidManifest.xml | 3 +- basic/end/build.gradle | 6 ++-- basic/end/gradle/libs.versions.toml | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- basic/start/app/build.gradle | 1 + basic/start/app/src/main/AndroidManifest.xml | 3 +- basic/start/build.gradle | 6 ++-- basic/start/gradle/libs.versions.toml | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 30 files changed, 119 insertions(+), 57 deletions(-) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 advanced/end/.idea/.gitignore create mode 100644 advanced/end/gradle.properties create mode 100644 advanced/end/local.properties create mode 100644 advanced/start/.idea/.gitignore create mode 100644 advanced/start/local.properties diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..f8fb63a5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ + +.idea/workspace.xml +advanced/start/.idea/compiler.xml +advanced/start/.idea/gradle.xml +advanced/start/.idea/jarRepositories.xml +advanced/start/.idea/ktfmt.xml +advanced/start/.idea/misc.xml +advanced/start/.idea/vcs.xml +advanced/end/.idea/vcs.xml +advanced/end/.idea/misc.xml +advanced/end/.idea/ktfmt.xml +advanced/end/.idea/jarRepositories.xml +advanced/end/.idea/gradle.xml +advanced/end/.idea/compiler.xml +advanced/end/.idea/workspace.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/advanced/end/.idea/.gitignore b/advanced/end/.idea/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/advanced/end/app/build.gradle b/advanced/end/app/build.gradle index 3aaf3f2d..65f318f7 100644 --- a/advanced/end/app/build.gradle +++ b/advanced/end/app/build.gradle @@ -48,6 +48,7 @@ android { buildFeatures { viewBinding = true } + namespace 'com.example.android.codelabs.paging' } dependencies { @@ -65,11 +66,15 @@ dependencies { implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycleVersion" + implementation "androidx.room:room-runtime:$roomVersion" implementation "androidx.room:room-ktx:$roomVersion" - implementation "androidx.paging:paging-runtime-ktx:$pagingVersion" kapt "androidx.room:room-compiler:$roomVersion" + implementation "androidx.room:room-paging:$roomVersion" + implementation "androidx.paging:paging-runtime-ktx:$pagingVersion" + + // retrofit implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion" diff --git a/advanced/end/app/src/main/AndroidManifest.xml b/advanced/end/app/src/main/AndroidManifest.xml index b16af235..e39388a1 100644 --- a/advanced/end/app/src/main/AndroidManifest.xml +++ b/advanced/end/app/src/main/AndroidManifest.xml @@ -15,8 +15,7 @@ ~ limitations under the License. --> - + (UIMODEL_COMPARATOR) when (uiModel) { is UiModel.RepoItem -> (holder as RepoViewHolder).bind(uiModel.repo) is UiModel.SeparatorItem -> (holder as SeparatorViewHolder).bind(uiModel.description) + else -> {throw UnsupportedOperationException("Unknown view")} } } } diff --git a/advanced/end/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesActivity.kt b/advanced/end/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesActivity.kt index 23316fa7..b12f5bca 100644 --- a/advanced/end/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesActivity.kt +++ b/advanced/end/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesActivity.kt @@ -181,15 +181,18 @@ class SearchRepositoriesActivity : AppCompatActivity() { ?.takeIf { it is LoadState.Error && repoAdapter.itemCount > 0 } ?: loadState.prepend - val isListEmpty = loadState.refresh is LoadState.NotLoading && repoAdapter.itemCount == 0 + val isListEmpty = + loadState.refresh is LoadState.NotLoading && repoAdapter.itemCount == 0 // show empty list emptyList.isVisible = isListEmpty // Only show the list if refresh succeeds, either from the the local db or the remote. - list.isVisible = loadState.source.refresh is LoadState.NotLoading || loadState.mediator?.refresh is LoadState.NotLoading + list.isVisible = + loadState.source.refresh is LoadState.NotLoading || loadState.mediator?.refresh is LoadState.NotLoading // Show loading spinner during initial load or refresh. progressBar.isVisible = loadState.mediator?.refresh is LoadState.Loading // Show the retry state if initial load or refresh fails. - retryButton.isVisible = loadState.mediator?.refresh is LoadState.Error && repoAdapter.itemCount == 0 + retryButton.isVisible = + loadState.mediator?.refresh is LoadState.Error && repoAdapter.itemCount == 0 // Toast on any error, regardless of whether it came from RemoteMediator or PagingSource val errorState = loadState.source.append as? LoadState.Error ?: loadState.source.prepend as? LoadState.Error diff --git a/advanced/end/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesViewModel.kt b/advanced/end/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesViewModel.kt index f4ccea8d..9874bdd5 100644 --- a/advanced/end/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesViewModel.kt +++ b/advanced/end/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesViewModel.kt @@ -25,6 +25,7 @@ import androidx.paging.insertSeparators import androidx.paging.map import com.example.android.codelabs.paging.data.GithubRepository import com.example.android.codelabs.paging.model.Repo +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.SharingStarted @@ -43,6 +44,7 @@ import kotlinx.coroutines.launch * ViewModel for the [SearchRepositoriesActivity] screen. * The ViewModel works with the [GithubRepository] to get the data. */ +@OptIn(ExperimentalCoroutinesApi::class) class SearchRepositoriesViewModel( private val repository: GithubRepository, private val savedStateHandle: SavedStateHandle @@ -61,8 +63,8 @@ class SearchRepositoriesViewModel( val accept: (UiAction) -> Unit init { - val initialQuery: String = savedStateHandle.get(LAST_SEARCH_QUERY) ?: DEFAULT_QUERY - val lastQueryScrolled: String = savedStateHandle.get(LAST_QUERY_SCROLLED) ?: DEFAULT_QUERY + val initialQuery: String = savedStateHandle[LAST_SEARCH_QUERY] ?: DEFAULT_QUERY + val lastQueryScrolled: String = savedStateHandle[LAST_QUERY_SCROLLED] ?: DEFAULT_QUERY val actionStateFlow = MutableSharedFlow() val searches = actionStateFlow .filterIsInstance() @@ -163,4 +165,4 @@ private val UiModel.RepoItem.roundedStarCount: Int private const val LAST_QUERY_SCROLLED: String = "last_query_scrolled" private const val LAST_SEARCH_QUERY: String = "last_search_query" -private const val DEFAULT_QUERY = "Android" \ No newline at end of file +private const val DEFAULT_QUERY = "Android" diff --git a/advanced/end/app/src/main/java/com/example/android/codelabs/paging/ui/ViewModelFactory.kt b/advanced/end/app/src/main/java/com/example/android/codelabs/paging/ui/ViewModelFactory.kt index c25d29c5..fcd159dd 100644 --- a/advanced/end/app/src/main/java/com/example/android/codelabs/paging/ui/ViewModelFactory.kt +++ b/advanced/end/app/src/main/java/com/example/android/codelabs/paging/ui/ViewModelFactory.kt @@ -30,7 +30,7 @@ class ViewModelFactory( private val repository: GithubRepository ) : AbstractSavedStateViewModelFactory(owner, null) { - override fun create( + override fun create( key: String, modelClass: Class, handle: SavedStateHandle diff --git a/advanced/end/build.gradle b/advanced/end/build.gradle index ddfc8303..c8791d82 100644 --- a/advanced/end/build.gradle +++ b/advanced/end/build.gradle @@ -17,13 +17,13 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.6.0' + ext.kotlin_version = '1.7.20' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.0.4' + classpath 'com.android.tools.build:gradle:7.3.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -40,18 +40,18 @@ task clean(type: Delete) { } ext { - compileSdkVersion = 31 - minSdkVersion = 15 - targetSdkVersion = 31 - supportLibVersion = '1.4.0' - coreVersion = '1.7.0' + compileSdkVersion = 33 + minSdkVersion = 24 + targetSdkVersion = 33 + supportLibVersion = '1.5.1' + coreVersion = '1.9.0' recyclerViewVersion = '1.2.1' - constraintLayoutVersion = '2.1.2' - materialVersion = '1.4.0' - lifecycleVersion = '2.4.0' - roomVersion = '2.3.0' - pagingVersion = '3.1.0' + constraintLayoutVersion = '2.1.4' + materialVersion = '1.7.0' + lifecycleVersion = '2.5.1' + roomVersion = '2.4.3' + pagingVersion = '3.1.1' retrofitVersion = '2.9.0' - okhttpLoggingInterceptorVersion = '4.9.0' - coroutines = '1.5.2' + okhttpLoggingInterceptorVersion = '5.0.0-alpha.11' + coroutines = '1.6.4' } diff --git a/advanced/end/gradle.properties b/advanced/end/gradle.properties new file mode 100644 index 00000000..364a6bb3 --- /dev/null +++ b/advanced/end/gradle.properties @@ -0,0 +1,15 @@ +## For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx1024m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +# +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +#Wed Oct 19 12:06:15 EDT 2022 +android.useAndroidX=true +android.enableJetifier=true diff --git a/advanced/end/gradle/wrapper/gradle-wrapper.properties b/advanced/end/gradle/wrapper/gradle-wrapper.properties index 33129af0..5f9e3797 100644 --- a/advanced/end/gradle/wrapper/gradle-wrapper.properties +++ b/advanced/end/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Nov 02 16:17:32 GMT 2020 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/advanced/end/local.properties b/advanced/end/local.properties new file mode 100644 index 00000000..fd71cab2 --- /dev/null +++ b/advanced/end/local.properties @@ -0,0 +1,8 @@ +## This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Mon Dec 26 13:24:16 EST 2022 +sdk.dir=/Users/johndelacruz/Library/Android/sdk diff --git a/advanced/start/.idea/.gitignore b/advanced/start/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/advanced/start/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/advanced/start/app/build.gradle b/advanced/start/app/build.gradle index 3aaf3f2d..d038c08b 100644 --- a/advanced/start/app/build.gradle +++ b/advanced/start/app/build.gradle @@ -48,6 +48,7 @@ android { buildFeatures { viewBinding = true } + namespace 'com.example.android.codelabs.paging' } dependencies { diff --git a/advanced/start/app/src/main/AndroidManifest.xml b/advanced/start/app/src/main/AndroidManifest.xml index b16af235..e39388a1 100644 --- a/advanced/start/app/src/main/AndroidManifest.xml +++ b/advanced/start/app/src/main/AndroidManifest.xml @@ -15,8 +15,7 @@ ~ limitations under the License. --> - + create( + override fun create( key: String, modelClass: Class, handle: SavedStateHandle diff --git a/advanced/start/build.gradle b/advanced/start/build.gradle index ddfc8303..c8791d82 100644 --- a/advanced/start/build.gradle +++ b/advanced/start/build.gradle @@ -17,13 +17,13 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.6.0' + ext.kotlin_version = '1.7.20' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.0.4' + classpath 'com.android.tools.build:gradle:7.3.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -40,18 +40,18 @@ task clean(type: Delete) { } ext { - compileSdkVersion = 31 - minSdkVersion = 15 - targetSdkVersion = 31 - supportLibVersion = '1.4.0' - coreVersion = '1.7.0' + compileSdkVersion = 33 + minSdkVersion = 24 + targetSdkVersion = 33 + supportLibVersion = '1.5.1' + coreVersion = '1.9.0' recyclerViewVersion = '1.2.1' - constraintLayoutVersion = '2.1.2' - materialVersion = '1.4.0' - lifecycleVersion = '2.4.0' - roomVersion = '2.3.0' - pagingVersion = '3.1.0' + constraintLayoutVersion = '2.1.4' + materialVersion = '1.7.0' + lifecycleVersion = '2.5.1' + roomVersion = '2.4.3' + pagingVersion = '3.1.1' retrofitVersion = '2.9.0' - okhttpLoggingInterceptorVersion = '4.9.0' - coroutines = '1.5.2' + okhttpLoggingInterceptorVersion = '5.0.0-alpha.11' + coroutines = '1.6.4' } diff --git a/advanced/start/gradle/wrapper/gradle-wrapper.properties b/advanced/start/gradle/wrapper/gradle-wrapper.properties index 33129af0..5f9e3797 100644 --- a/advanced/start/gradle/wrapper/gradle-wrapper.properties +++ b/advanced/start/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Nov 02 16:17:32 GMT 2020 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/advanced/start/local.properties b/advanced/start/local.properties new file mode 100644 index 00000000..291d4bcc --- /dev/null +++ b/advanced/start/local.properties @@ -0,0 +1,8 @@ +## This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Mon Dec 26 13:14:04 EST 2022 +sdk.dir=/Users/johndelacruz/Library/Android/sdk diff --git a/basic/end/app/build.gradle b/basic/end/app/build.gradle index b557821f..4369dc5d 100644 --- a/basic/end/app/build.gradle +++ b/basic/end/app/build.gradle @@ -51,6 +51,7 @@ android { buildFeatures { viewBinding = true } + namespace 'com.example.android.codelabs.paging' } dependencies { diff --git a/basic/end/app/src/main/AndroidManifest.xml b/basic/end/app/src/main/AndroidManifest.xml index e6052087..ad804a51 100644 --- a/basic/end/app/src/main/AndroidManifest.xml +++ b/basic/end/app/src/main/AndroidManifest.xml @@ -15,8 +15,7 @@ ~ limitations under the License. --> - + - +