Skip to content

Commit

Permalink
Bumped dependencies. Replaced deprecated code with new ones.
Browse files Browse the repository at this point in the history
  • Loading branch information
grad1e committed Sep 25, 2021
1 parent ade59bd commit 26ce769
Show file tree
Hide file tree
Showing 25 changed files with 148 additions and 122 deletions.
16 changes: 0 additions & 16 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 24 additions & 25 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 3,9 @@ plugins {
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'androidx.navigation.safeargs'
}
apply plugin: "androidx.navigation.safeargs"

def compose_version = '1.0.0-alpha09'
android {
compileSdkVersion 30

Expand Down Expand Up @@ -41,22 40,22 @@ android {
// Disabling coroutine's ExperimentalCoroutinesApi warning
freeCompilerArgs = [
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xuse-experimental=kotlin.time.ExperimentalTime"
"-Xuse-experimental=kotlin.time.ExperimentalTime",
"-Xopt-in=coil.annotation.ExperimentalCoilApi"
]
}

composeOptions {
kotlinCompilerVersion kotlin_version
kotlinCompilerExtensionVersion compose_version
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'

// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
Expand All @@ -70,15 69,12 @@ dependencies {
implementation "androidx.compose.material:material:$compose_version"

// Hilt
def androidx_hilt_version = '1.0.0-alpha02'
implementation "com.google.dagger:hilt-android:$hilt_version"
implementation "androidx.hilt:hilt-lifecycle-viewmodel:$androidx_hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
kapt "androidx.hilt:hilt-lifecycle-viewmodel:$androidx_hilt_version"
kapt "androidx.hilt:hilt-compiler:$androidx_hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"
implementation "androidx.hilt:hilt-navigation-fragment:1.0.0"

// Room
def room_version = "2.2.6"
def room_version = "2.3.0"
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"
Expand All @@ -90,24 86,27 @@ dependencies {
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"

// Moshi : Moshi
implementation 'com.squareup.moshi:moshi:1.11.0'
implementation 'com.squareup.moshi:moshi:1.12.0'
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.12.0'
implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.11.0'

testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"

// Timber : No-nonsense injectable logging.
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.jakewharton.timber:timber:5.0.1'

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

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

// LiveData Kotlin Extensions : Kotlin extensions for 'livedata' artifact
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-rc01'
// Kotlin Lifecycle KTX
def lifecycle_version = "2.3.1"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 6,7 @@ import androidx.room.TypeConverters
import com.theapache64.topcorn2.data.local.daos.MoviesDao
import com.theapache64.topcorn2.data.remote.Movie

@Database(entities = [Movie::class], version = 3)
@Database(entities = [Movie::class], version = 3, exportSchema = false)
@TypeConverters(Converters::class)
abstract class AppDatabase : RoomDatabase() {
abstract fun movieDao(): MoviesDao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 11,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOn
import javax.inject.Inject
import kotlin.time.Duration
import kotlin.time.ExperimentalTime
import kotlin.time.hours

class MoviesRepo @Inject constructor(
private val sharedPref: SharedPreferences,
Expand All @@ -21,7 21,7 @@ class MoviesRepo @Inject constructor(
) {

companion object {
private val MOVIE_EXPIRY_IN_MILLIS = 1.hours.inMilliseconds.toLong()
private val MOVIE_EXPIRY_IN_MILLIS = Duration.hours(1).inWholeMilliseconds
private const val KEY_LAST_SYNCED = "last_synced"
}

Expand Down Expand Up @@ -53,7 53,7 @@ class MoviesRepo @Inject constructor(
}.asFlow().flowOn(Dispatchers.IO)
}

suspend fun getMovie(movieId : Int) = moviesDao.getMovie(movieId)
suspend fun getMovie(movieId: Int) = moviesDao.getMovie(movieId)

@ExperimentalTime
private fun isExpired(lastSynced: Long): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 6,14 @@ import com.theapache64.topcorn2.data.local.AppDatabase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
object DatabaseModule {

private const val DB_NAME = "com.theapache64.topcorn2_db"
private const val DB_NAME = "com.theapache64.topcorn2_db.db"

@Provides
fun provideAppDatabase(@ApplicationContext context: Context): AppDatabase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 6,13 @@ import com.theapache64.topcorn2.utils.calladapter.flow.FlowResourceCallAdapterFa
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import javax.inject.Singleton

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
object NetworkModule {

@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 5,14 @@ import android.content.SharedPreferences
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent

/**
* Created by theapache64 : Jan 04 Mon,2021 @ 00:31
*/
@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
object PreferenceModule {
@Provides
fun provideSharedPreference(@ApplicationContext context: Context): SharedPreferences {
Expand Down
17 changes: 10 additions & 7 deletions app/src/main/java/com/theapache64/topcorn2/ui/common/Poster.kt
Original file line number Diff line number Diff line change
@@ -1,12 1,13 @@
package com.theapache64.topcorn2.ui.common

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.material.Card
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import coil.compose.rememberImagePainter
import coil.size.Scale
import com.theapache64.topcorn2.data.remote.Movie
import dev.chrisbanes.accompanist.coil.CoilImage

@Composable
fun Poster(
Expand All @@ -17,11 18,13 @@ fun Poster(
Card(
modifier = Modifier.clickable(onClick = { onMovieClicked(movie) })
) {
CoilImage(
data = movie.thumbUrl,
fadeIn = true,
contentScale = ContentScale.Crop,
modifier = modifier
Image(
painter = rememberImagePainter(data = movie.thumbUrl, builder = {
crossfade(true)
scale(Scale.FILL)
}),
modifier = modifier,
contentDescription = null
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 7,7 @@ import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextAlign
Expand All @@ -30,8 31,9 @@ fun RetryMessage(
) {
Image(
modifier = Modifier
.preferredSize(48.dp),
imageVector = vectorResource(id = R.drawable.ic_warning)
.requiredSize(48.dp),
imageVector = ImageVector.vectorResource(id = R.drawable.ic_warning),
contentDescription = null
)

Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 3,6 @@ package com.theapache64.topcorn2.ui.main
import android.os.Bundle
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.findNavController
import com.theapache64.topcorn2.R
import dagger.hilt.android.AndroidEntryPoint

Expand All @@ -18,7 17,7 @@ class MainActivity : AppCompatActivity() {

}

override fun onBackPressed() {
/*override fun onBackPressed() {
findNavController(R.id.nav_host).let { navController ->
navController.currentDestination.let { currentDestination ->
if (currentDestination?.id == R.id.movies_fragment) {
Expand All @@ -28,5 27,5 @@ class MainActivity : AppCompatActivity() {
}
}
}
}
}*/
}
Original file line number Diff line number Diff line change
@@ -1,13 1,13 @@
package com.theapache64.topcorn2.ui.main

import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.ViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

/**
* Created by theapache64 : Jan 03 Sun,2021 @ 21:14
*/
class MainViewModel @ViewModelInject constructor() : ViewModel() {
@HiltViewModel
class MainViewModel @Inject constructor() : ViewModel() {

}
Loading

0 comments on commit 26ce769

Please sign in to comment.