Skip to content

Commit 4c9b0f2

Browse files
committed
update android studio F
1 parent a1371ec commit 4c9b0f2

File tree

7 files changed

+83
-62
lines changed

7 files changed

+83
-62
lines changed

app/build.gradle.kts

Lines changed: 58 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,12 @@ android {
120120
}
121121
}
122122
}
123-
124123
compileOptions {
125-
sourceCompatibility(JavaVersion.VERSION_11)
126-
targetCompatibility(JavaVersion.VERSION_11)
124+
sourceCompatibility(JavaVersion.VERSION_17)
125+
targetCompatibility(JavaVersion.VERSION_17)
127126
}
128127
kotlinOptions {
129-
jvmTarget = "11"
128+
jvmTarget = JavaVersion.VERSION_17.toString()
130129
// freeCompilerArgs = listOf("-Xallow-result-return-type")
131130
}
132131
// https://developer.android.com/topic/libraries/data-binding
@@ -135,7 +134,7 @@ android {
135134
compose = true
136135
}
137136
composeOptions {
138-
kotlinCompilerExtensionVersion = "1.4.0"
137+
kotlinCompilerExtensionVersion = "1.4.1"
139138
}
140139
lint {
141140
checkReleaseBuilds = false
@@ -150,32 +149,32 @@ dependencies {
150149
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
151150
implementation("androidx.recyclerview:recyclerview:1.3.0")
152151
implementation("com.google.android.material:material:1.8.0")
153-
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10")
154-
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.0")
152+
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.20")
153+
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.20")
155154
implementation("androidx.multidex:multidex:2.0.1")
156155

157156
// List of KTX extensions
158157
// https://developer.android.com/kotlin/ktx/extensions-list
159-
implementation("androidx.core:core-ktx:1.9.0")
160-
implementation("androidx.activity:activity-ktx:1.6.1")
161-
implementation("androidx.fragment:fragment-ktx:1.5.5")
158+
implementation("androidx.core:core-ktx:1.10.0")
159+
implementation("androidx.activity:activity-ktx:1.7.0")
160+
implementation("androidx.fragment:fragment-ktx:1.5.6")
162161

163162
// Lifecycle
164163
// https://developer.android.com/jetpack/androidx/releases/lifecycle
165-
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.0")
166-
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.0")
167-
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.0")
168-
implementation("androidx.lifecycle:lifecycle-common-java8:2.6.0")
164+
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1")
165+
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.1")
166+
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
167+
implementation("androidx.lifecycle:lifecycle-common-java8:2.6.1")
169168

170169
// Preferences DataStore
171170
// https://android-developers.googleblog.com/2020/09/prefer-storing-data-with-jetpack.html
172171
implementation("androidx.datastore:datastore-preferences:1.0.0")
173172

174173
// room
175174
// https://developer.android.com/topic/libraries/architecture/room
176-
implementation("androidx.room:room-runtime:2.5.0")
177-
kapt("androidx.room:room-compiler:2.5.0")
178-
implementation("androidx.room:room-ktx:2.5.0")
175+
implementation("androidx.room:room-runtime:2.5.1")
176+
kapt("androidx.room:room-compiler:2.5.1")
177+
implementation("androidx.room:room-ktx:2.5.1")
179178

180179
// paging
181180
// https://developer.android.com/topic/libraries/architecture/paging
@@ -230,7 +229,7 @@ dependencies {
230229

231230
// firebase
232231
// https://firebase.google.com/docs/android/setup
233-
implementation(platform("com.google.firebase:firebase-bom:31.2.3"))
232+
implementation(platform("com.google.firebase:firebase-bom:31.5.0"))
234233
implementation("com.google.firebase:firebase-analytics-ktx")
235234
implementation("com.google.firebase:firebase-crashlytics-ktx")
236235
implementation("com.google.firebase:firebase-messaging-ktx")
@@ -248,12 +247,12 @@ dependencies {
248247

249248
// unit test
250249
testImplementation("junit:junit:4.13.2")
251-
testImplementation("org.mockito:mockito-core:5.2.0")
250+
testImplementation("org.mockito:mockito-core:5.3.0")
252251
// testImplementation("org.mockito:mockito-inline:3.3.3")
253-
testImplementation("io.mockk:mockk:1.13.4")
252+
testImplementation("io.mockk:mockk:1.13.5")
254253
testImplementation("androidx.arch.core:core-testing:2.2.0")
255254
testImplementation("com.squareup.okhttp3:mockwebserver:5.0.0-alpha.2")
256-
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.10")
255+
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.20")
257256
// testImplementation("org.robolectric:robolectric:4.3")
258257

259258
/**
@@ -373,45 +372,46 @@ dependencies {
373372
// compose
374373
// https://developer.android.com/jetpack/compose/interop/adding
375374
// https://developer.android.com/jetpack/compose/setup
376-
implementation("androidx.compose:compose-bom:2023.01.00")
377-
androidTestImplementation("androidx.compose:compose-bom:2023.01.00")
378-
// Android Studio Preview support
379-
implementation("androidx.compose.ui:ui-tooling-preview")
380-
debugImplementation("androidx.compose.ui:ui-tooling")
381-
// Animations
382-
implementation("androidx.compose.animation:animation")
375+
// implementation("androidx.compose.compiler:compiler:1.4.5")
376+
// implementation("androidx.compose:compose-bom:2023.04.00")
377+
// androidTestImplementation("androidx.compose:compose-bom:2023.04.00")
383378
// Foundation (Border, Background, Box, Image, Scroll, shapes, animations, etc.)
384-
implementation("androidx.compose.foundation:foundation")
379+
implementation("androidx.compose.foundation:foundation:1.4.1")
385380
// or Material Design 2
386-
implementation("androidx.compose.material:material")
387-
// Material Design
388-
implementation("androidx.compose.material3:material3")
381+
implementation("androidx.compose.material:material:1.4.1")
382+
// Material Design 3
383+
implementation("androidx.compose.material3:material3:1.1.0-beta02")
384+
// Android Studio Preview support
385+
implementation("androidx.compose.ui:ui-tooling-preview:1.4.1")
386+
debugImplementation("androidx.compose.ui:ui-tooling:1.4.1")
387+
// UI Tests
388+
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.5.0-alpha02")
389+
debugImplementation("androidx.compose.ui:ui-test-manifest:1.4.1")
390+
// Animations
391+
implementation("androidx.compose.animation:animation:1.4.1")
389392
// Constraint layout
390393
implementation("androidx.constraintlayout:constraintlayout-compose:1.0.1")
391394
// Optional - Included automatically by material, only add when you need
392395
// the icons but not the material library (e.g. when using Material3 or a
393396
// custom design system based on Foundation)
394397
// implementation("androidx.compose.material:material-icons-core")
395398
// Optional - Add full set of material icons
396-
implementation("androidx.compose.material:material-icons-extended")
399+
implementation("androidx.compose.material:material-icons-extended:1.4.1")
397400
// Optional - Add window size utils
398-
implementation("androidx.compose.material3:material3-window-size-class")
401+
implementation("androidx.compose.material3:material3-window-size-class:1.0.1")
399402
// Optional - Integration with activities
400-
implementation("androidx.activity:activity-compose:1.6.1")
403+
implementation("androidx.activity:activity-compose:1.7.0")
401404
// Optional - Integration with ViewModels
402-
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.0")
405+
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1")
403406
// Optional - Integration with LiveData
404-
implementation("androidx.compose.runtime:runtime-livedata")
405-
// UI Tests
406-
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
407-
debugImplementation("androidx.compose.ui:ui-test-manifest")
407+
implementation("androidx.compose.runtime:runtime-livedata:1.4.1")
408408
// navigation
409409
implementation("androidx.navigation:navigation-compose:2.5.3")
410410
implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
411411
// https://github.com/skydoves/landscapist
412-
implementation("com.github.skydoves:landscapist-bom:2.1.7")
413-
implementation("com.github.skydoves:landscapist-glide")
414-
implementation("com.github.skydoves:landscapist-placeholder")
412+
// implementation("com.github.skydoves:landscape-bom:2.1.7")
413+
implementation("com.github.skydoves:landscapist-glide:2.1.11")
414+
implementation("com.github.skydoves:landscapist-placeholder:2.1.11")
415415
// https://google.github.io/accompanist/
416416
// https://github.com/google/accompanist
417417
val accompanistVersion = "0.28.0"
@@ -461,15 +461,27 @@ project.afterEvaluate {
461461
sourceName = buildTypeName
462462
} else {
463463
sourcePath = "${productFlavorName}/${buildTypeName}"
464-
sourceName = "${productFlavorName}${buildTypeName.capitalize()}"
464+
sourceName = "${productFlavorName}${buildTypeName.replaceFirstChar {
465+
if (it.isLowerCase()) it.titlecase(
466+
Locale.getDefault()
467+
) else it.toString()
468+
}}"
465469
}
466-
val testTaskName = "test${sourceName.capitalize()}UnitTest"
470+
val testTaskName = "test${sourceName.replaceFirstChar {
471+
if (it.isLowerCase()) it.titlecase(
472+
Locale.getDefault()
473+
) else it.toString()
474+
}}UnitTest"
467475
// Create coverage task of form 'testFlavorTypeCoverage' depending on 'testFlavorTypeUnitTest'
468476
task<JacocoReport>("${testTaskName}Coverage") {
469477
//where store all test to run follow second way above
470478
group = "coverage"
471479
description =
472-
"Generate Jacoco coverage reports on the ${sourceName.capitalize()} build."
480+
"Generate Jacoco coverage reports on the ${sourceName.replaceFirstChar {
481+
if (it.isLowerCase()) it.titlecase(
482+
Locale.getDefault()
483+
) else it.toString()
484+
}} build."
473485
val excludeFiles = arrayListOf(
474486
"**/R.class", "**/R$*.class", "**/BuildConfig.*", "**/Manifest*.*",
475487
"**/*Test*.*", "android/**/*.*",

app/src/main/java/com/example/moviedb/ui/screen/moviedetail/MovieDetailFragment.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import android.os.Bundle
44
import android.view.View
55
import android.widget.ImageView
66
import androidx.fragment.app.viewModels
7+
import androidx.lifecycle.Lifecycle
78
import androidx.lifecycle.lifecycleScope
9+
import androidx.lifecycle.repeatOnLifecycle
810
import androidx.navigation.fragment.FragmentNavigatorExtras
911
import androidx.navigation.fragment.navArgs
1012
import com.example.moviedb.R
@@ -14,6 +16,7 @@ import com.example.moviedb.ui.base.getNavController
1416
import com.example.moviedb.utils.setSingleClick
1517
import dagger.hilt.android.AndroidEntryPoint
1618
import kotlinx.coroutines.flow.collectLatest
19+
import kotlinx.coroutines.launch
1720

1821
@AndroidEntryPoint
1922
class MovieDetailFragment : BaseFragment<FragmentMovieDetailBinding, MovieDetailViewModel>() {
@@ -50,9 +53,11 @@ class MovieDetailFragment : BaseFragment<FragmentMovieDetailBinding, MovieDetail
5053
if (viewBinding.recyclerCast.adapter == null) {
5154
viewBinding.recyclerCast.adapter = castAdapter
5255
}
53-
lifecycleScope.launchWhenStarted {
54-
viewModel.castList.collectLatest { castList ->
55-
castAdapter.submitList(castList)
56+
lifecycleScope.launch {
57+
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
58+
viewModel.castList.collectLatest { castList ->
59+
castAdapter.submitList(castList)
60+
}
5661
}
5762
}
5863
}

app/src/main/java/com/example/moviedb/ui/screen/splash/SplashFragment.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package com.example.moviedb.ui.screen.splash
33
import android.os.Bundle
44
import android.view.View
55
import androidx.fragment.app.viewModels
6+
import androidx.lifecycle.Lifecycle
67
import androidx.lifecycle.lifecycleScope
7-
import androidx.lifecycle.whenStarted
8+
import androidx.lifecycle.repeatOnLifecycle
89
import com.example.moviedb.R
910
import com.example.moviedb.databinding.FragmentSplashBinding
1011
import com.example.moviedb.ui.base.BaseFragment
@@ -22,12 +23,13 @@ class SplashFragment : BaseFragment<FragmentSplashBinding, BaseViewModel>() {
2223
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
2324
super.onViewCreated(view, savedInstanceState)
2425
lifecycleScope.launch {
25-
whenStarted {
26+
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
2627
viewModel.splashViewStateFlow.collect { state ->
2728
when (state) {
2829
is SplashViewState.Idle -> {
2930
// do nothing
3031
}
32+
3133
is SplashViewState.NavigateToHome -> {
3234
navigateToHome()
3335
}

app/src/main/java/com/example/moviedb/ui/widgets/NavigationExtension.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import androidx.lifecycle.LiveData
1212
import androidx.lifecycle.MutableLiveData
1313
import androidx.navigation.NavController
1414
import androidx.navigation.fragment.NavHostFragment
15-
import com.example.moviedb.R
1615
import com.google.android.material.bottomnavigation.BottomNavigationView
1716

1817
/**
@@ -93,10 +92,10 @@ fun BottomNavigationView.setupWithNavController(
9392
// to it, creating the fixed started destination.
9493
fragmentManager.beginTransaction()
9594
.setCustomAnimations(
96-
R.anim.nav_default_enter_anim,
97-
R.anim.nav_default_exit_anim,
98-
R.anim.nav_default_pop_enter_anim,
99-
R.anim.nav_default_pop_exit_anim
95+
androidx.navigation.ui.R.anim.nav_default_enter_anim,
96+
androidx.navigation.ui.R.anim.nav_default_exit_anim,
97+
androidx.navigation.ui.R.anim.nav_default_pop_enter_anim,
98+
androidx.navigation.ui.R.anim.nav_default_pop_exit_anim
10099
)
101100
.attach(selectedFragment)
102101
.setPrimaryNavigationFragment(selectedFragment)

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ buildscript {
22
repositories {
33
google()
44
mavenCentral()
5-
maven("https://maven.google.com")
5+
// maven("https://maven.google.com")
66
}
77
dependencies {
8-
classpath("com.android.tools.build:gradle:7.4.2")
8+
classpath("com.android.tools.build:gradle:8.0.0")
99
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0")
1010
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3")
1111
classpath("com.google.dagger:hilt-android-gradle-plugin:2.44.2")
1212
// classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Libs.kotlinVersion}")
1313
// classpath("androidx.navigation:navigation-safe-args-gradle-plugin:${Libs.navigationVersion}")
1414
// classpath("com.google.dagger:hilt-android-gradle-plugin:${Libs.daggerHiltVersion}")
1515
classpath("com.google.gms:google-services:4.3.15")
16-
classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.4")
16+
classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.5")
1717
}
1818
}
1919

2020
allprojects {
2121
repositories {
2222
google()
2323
mavenCentral()
24-
maven("https://maven.google.com")
24+
// maven("https://maven.google.com")
2525
}
2626
}
2727

gradle.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ android.databinding.incremental=true
2222
# Kotlin code style for this project: "official" or "obsolete":
2323
kotlin.code.style=official
2424
kapt.incremental.apt=true
25-
#org.gradle.unsafe.configuration-cache=true
25+
android.defaults.buildfeatures.buildconfig=true
26+
android.nonTransitiveRClass=true
27+
android.nonFinalResIds=false
28+
org.gradle.unsafe.configuration-cache=true
2629
#org.gradle.caching=true

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip

0 commit comments

Comments
 (0)