Skip to content

Commit 047b701

Browse files
authored
Merge pull request #5 from grad1e/refactor/new-items
Bumped dependencies. Replaced deprecated code with new ones.
2 parents ade59bd + 26ce769 commit 047b701

25 files changed

Lines changed: 148 additions & 122 deletions

.idea/codeStyles/Project.xml

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ plugins {
33
id 'kotlin-android'
44
id 'kotlin-kapt'
55
id 'dagger.hilt.android.plugin'
6+
id 'androidx.navigation.safeargs'
67
}
7-
apply plugin: "androidx.navigation.safeargs"
88

9-
def compose_version = '1.0.0-alpha09'
109
android {
1110
compileSdkVersion 30
1211

@@ -41,22 +40,22 @@ android {
4140
// Disabling coroutine's ExperimentalCoroutinesApi warning
4241
freeCompilerArgs += [
4342
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
44-
"-Xuse-experimental=kotlin.time.ExperimentalTime"
43+
"-Xuse-experimental=kotlin.time.ExperimentalTime",
44+
"-Xopt-in=coil.annotation.ExperimentalCoilApi"
4545
]
4646
}
4747

4848
composeOptions {
49-
kotlinCompilerVersion kotlin_version
5049
kotlinCompilerExtensionVersion compose_version
5150
}
5251
}
5352

5453
dependencies {
5554

56-
implementation 'androidx.core:core-ktx:1.3.2'
57-
implementation 'androidx.appcompat:appcompat:1.2.0'
58-
implementation 'com.google.android.material:material:1.2.1'
59-
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
55+
implementation 'androidx.core:core-ktx:1.6.0'
56+
implementation 'androidx.appcompat:appcompat:1.3.1'
57+
implementation 'com.google.android.material:material:1.4.0'
58+
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
6059

6160
// Navigation
6261
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
@@ -70,15 +69,12 @@ dependencies {
7069
implementation "androidx.compose.material:material:$compose_version"
7170

7271
// Hilt
73-
def androidx_hilt_version = '1.0.0-alpha02'
7472
implementation "com.google.dagger:hilt-android:$hilt_version"
75-
implementation "androidx.hilt:hilt-lifecycle-viewmodel:$androidx_hilt_version"
76-
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
77-
kapt "androidx.hilt:hilt-lifecycle-viewmodel:$androidx_hilt_version"
78-
kapt "androidx.hilt:hilt-compiler:$androidx_hilt_version"
73+
kapt "com.google.dagger:hilt-compiler:$hilt_version"
74+
implementation "androidx.hilt:hilt-navigation-fragment:1.0.0"
7975

8076
// Room
81-
def room_version = "2.2.6"
77+
def room_version = "2.3.0"
8278
implementation "androidx.room:room-runtime:$room_version"
8379
implementation "androidx.room:room-ktx:$room_version"
8480
kapt "androidx.room:room-compiler:$room_version"
@@ -90,24 +86,27 @@ dependencies {
9086
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
9187

9288
// Moshi : Moshi
93-
implementation 'com.squareup.moshi:moshi:1.11.0'
89+
implementation 'com.squareup.moshi:moshi:1.12.0'
90+
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.12.0'
9491
implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
95-
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.11.0'
9692

97-
testImplementation 'junit:junit:4.13.1'
98-
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
99-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
93+
testImplementation 'junit:junit:4.13.2'
94+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
95+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
10096
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
10197

10298
// Timber : No-nonsense injectable logging.
103-
implementation 'com.jakewharton.timber:timber:4.7.1'
99+
implementation 'com.jakewharton.timber:timber:5.0.1'
104100

105101
// Kotlinx Coroutines Core : Coroutines support libraries for Kotlin
106-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
102+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
107103

108-
// Accompanist Coil Integration : A collection of utilities for Jetpack Compose
109-
implementation 'dev.chrisbanes.accompanist:accompanist-coil:0.4.1'
104+
// Coil - Image loading library
105+
implementation("io.coil-kt:coil-compose:1.3.2")
110106

111-
// LiveData Kotlin Extensions : Kotlin extensions for 'livedata' artifact
112-
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-rc01'
107+
// Kotlin Lifecycle KTX
108+
def lifecycle_version = "2.3.1"
109+
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
110+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
111+
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
113112
}

app/src/main/java/com/theapache64/topcorn2/data/local/AppDatabase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import androidx.room.TypeConverters
66
import com.theapache64.topcorn2.data.local.daos.MoviesDao
77
import com.theapache64.topcorn2.data.remote.Movie
88

9-
@Database(entities = [Movie::class], version = 3)
9+
@Database(entities = [Movie::class], version = 3, exportSchema = false)
1010
@TypeConverters(Converters::class)
1111
abstract class AppDatabase : RoomDatabase() {
1212
abstract fun movieDao(): MoviesDao

app/src/main/java/com/theapache64/topcorn2/data/repo/MoviesRepo.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import kotlinx.coroutines.Dispatchers
1111
import kotlinx.coroutines.flow.Flow
1212
import kotlinx.coroutines.flow.flowOn
1313
import javax.inject.Inject
14+
import kotlin.time.Duration
1415
import kotlin.time.ExperimentalTime
15-
import kotlin.time.hours
1616

1717
class MoviesRepo @Inject constructor(
1818
private val sharedPref: SharedPreferences,
@@ -21,7 +21,7 @@ class MoviesRepo @Inject constructor(
2121
) {
2222

2323
companion object {
24-
private val MOVIE_EXPIRY_IN_MILLIS = 1.hours.inMilliseconds.toLong()
24+
private val MOVIE_EXPIRY_IN_MILLIS = Duration.hours(1).inWholeMilliseconds
2525
private const val KEY_LAST_SYNCED = "last_synced"
2626
}
2727

@@ -53,7 +53,7 @@ class MoviesRepo @Inject constructor(
5353
}.asFlow().flowOn(Dispatchers.IO)
5454
}
5555

56-
suspend fun getMovie(movieId : Int) = moviesDao.getMovie(movieId)
56+
suspend fun getMovie(movieId: Int) = moviesDao.getMovie(movieId)
5757

5858
@ExperimentalTime
5959
private fun isExpired(lastSynced: Long): Boolean {

app/src/main/java/com/theapache64/topcorn2/di/modules/DatabaseModule.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import com.theapache64.topcorn2.data.local.AppDatabase
66
import dagger.Module
77
import dagger.Provides
88
import dagger.hilt.InstallIn
9-
import dagger.hilt.android.components.ApplicationComponent
109
import dagger.hilt.android.qualifiers.ApplicationContext
10+
import dagger.hilt.components.SingletonComponent
1111

1212
@Module
13-
@InstallIn(ApplicationComponent::class)
13+
@InstallIn(SingletonComponent::class)
1414
object DatabaseModule {
1515

16-
private const val DB_NAME = "com.theapache64.topcorn2_db"
16+
private const val DB_NAME = "com.theapache64.topcorn2_db.db"
1717

1818
@Provides
1919
fun provideAppDatabase(@ApplicationContext context: Context): AppDatabase {

app/src/main/java/com/theapache64/topcorn2/di/modules/NetworkModule.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import com.theapache64.topcorn2.utils.calladapter.flow.FlowResourceCallAdapterFa
66
import dagger.Module
77
import dagger.Provides
88
import dagger.hilt.InstallIn
9-
import dagger.hilt.android.components.ApplicationComponent
9+
import dagger.hilt.components.SingletonComponent
1010
import retrofit2.Retrofit
1111
import retrofit2.converter.moshi.MoshiConverterFactory
1212
import javax.inject.Singleton
1313

1414
@Module
15-
@InstallIn(ApplicationComponent::class)
15+
@InstallIn(SingletonComponent::class)
1616
object NetworkModule {
1717

1818
@Singleton

app/src/main/java/com/theapache64/topcorn2/di/modules/PreferenceModule.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import android.content.SharedPreferences
55
import dagger.Module
66
import dagger.Provides
77
import dagger.hilt.InstallIn
8-
import dagger.hilt.android.components.ApplicationComponent
98
import dagger.hilt.android.qualifiers.ApplicationContext
9+
import dagger.hilt.components.SingletonComponent
1010

1111
/**
1212
* Created by theapache64 : Jan 04 Mon,2021 @ 00:31
1313
*/
1414
@Module
15-
@InstallIn(ApplicationComponent::class)
15+
@InstallIn(SingletonComponent::class)
1616
object PreferenceModule {
1717
@Provides
1818
fun provideSharedPreference(@ApplicationContext context: Context): SharedPreferences {
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package com.theapache64.topcorn2.ui.common
22

3+
import androidx.compose.foundation.Image
34
import androidx.compose.foundation.clickable
45
import androidx.compose.material.Card
56
import androidx.compose.runtime.Composable
67
import androidx.compose.ui.Modifier
7-
import androidx.compose.ui.layout.ContentScale
8+
import coil.compose.rememberImagePainter
9+
import coil.size.Scale
810
import com.theapache64.topcorn2.data.remote.Movie
9-
import dev.chrisbanes.accompanist.coil.CoilImage
1011

1112
@Composable
1213
fun Poster(
@@ -17,11 +18,13 @@ fun Poster(
1718
Card(
1819
modifier = Modifier.clickable(onClick = { onMovieClicked(movie) })
1920
) {
20-
CoilImage(
21-
data = movie.thumbUrl,
22-
fadeIn = true,
23-
contentScale = ContentScale.Crop,
24-
modifier = modifier
21+
Image(
22+
painter = rememberImagePainter(data = movie.thumbUrl, builder = {
23+
crossfade(true)
24+
scale(Scale.FILL)
25+
}),
26+
modifier = modifier,
27+
contentDescription = null
2528
)
2629
}
2730
}

0 commit comments

Comments
 (0)