Skip to content

Commit

Permalink
update libs
Browse files Browse the repository at this point in the history
  • Loading branch information
quanda-0562 committed Oct 25, 2023
1 parent 8f7bad0 commit df499b8
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 78 deletions.
103 changes: 52 additions & 51 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {
applicationId = "com.example.moviedb"
buildToolsVersion = "34.0.0"
minSdk = 23
compileSdk = 33
compileSdk = 34
targetSdk = 34
multiDexEnabled = true
vectorDrawables {
Expand Down Expand Up @@ -139,11 +139,11 @@ android {
}
composeOptions {
// check version here https://developer.android.com/jetpack/androidx/releases/compose-kotlin
kotlinCompilerExtensionVersion = "1.4.8"
kotlinCompilerExtensionVersion = "1.5.3"
}
lint {
checkReleaseBuilds = false
abortOnError = false
// checkReleaseBuilds = false
// abortOnError = false
}
}

Expand All @@ -152,50 +152,50 @@ dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.recyclerview:recyclerview:1.3.0")
implementation("com.google.android.material:material:1.9.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.22")
implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation("com.google.android.material:material:1.10.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.10")
implementation("androidx.multidex:multidex:2.0.1")

// List of KTX extensions
// https://developer.android.com/kotlin/ktx/extensions-list
implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.activity:activity-ktx:1.7.2")
implementation("androidx.fragment:fragment-ktx:1.6.0")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.activity:activity-ktx:1.8.0")
implementation("androidx.fragment:fragment-ktx:1.6.1")

// Lifecycle
// https://developer.android.com/jetpack/androidx/releases/lifecycle
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")
// implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
implementation("androidx.lifecycle:lifecycle-common-java8:2.6.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation("androidx.lifecycle:lifecycle-common-java8:2.6.2")

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

// room
// https://developer.android.com/topic/libraries/architecture/room
implementation("androidx.room:room-runtime:2.5.2")
ksp("androidx.room:room-compiler:2.5.2")
implementation("androidx.room:room-ktx:2.5.2")
implementation("androidx.room:room-runtime:2.6.0")
ksp("androidx.room:room-compiler:2.6.0")
implementation("androidx.room:room-ktx:2.6.0")

// paging
// https://developer.android.com/topic/libraries/architecture/paging
implementation("androidx.paging:paging-runtime-ktx:3.1.1")
implementation("androidx.paging:paging-runtime-ktx:3.2.1")

// navigation
// https://developer.android.com/jetpack/androidx/releases/navigation
implementation("androidx.navigation:navigation-runtime-ktx:2.6.0")
implementation("androidx.navigation:navigation-fragment-ktx:2.6.0")
implementation("androidx.navigation:navigation-ui-ktx:2.6.0")
implementation("androidx.navigation:navigation-runtime-ktx:2.7.4")
implementation("androidx.navigation:navigation-fragment-ktx:2.7.4")
implementation("androidx.navigation:navigation-ui-ktx:2.7.4")

// coroutines
// https://github.com/Kotlin/kotlinx.coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.2")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")

// moshi
implementation("com.squareup.moshi:moshi-kotlin:1.15.0")
Expand All @@ -205,7 +205,7 @@ dependencies {
// https://github.com/square/retrofit
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-moshi:2.9.0")
implementation("com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.10")
implementation("com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.11")

// OkHttpProfiler
// https://github.com/itkacher/OkHttpProfiler
Expand All @@ -218,12 +218,13 @@ dependencies {

// glide
// https://github.com/bumptech/glide
implementation("com.github.bumptech.glide:glide:4.15.1")
ksp("com.github.bumptech.glide:ksp:4.15.1")
implementation("com.github.bumptech.glide:glide:4.16.0")
ksp("com.github.bumptech.glide:ksp:4.16.0")

// dagger hilt
implementation("com.google.dagger:hilt-android:2.46.1")
kapt("com.google.dagger:hilt-android-compiler:2.46.1")
// TODO change to ksp https://github.com/google/dagger/issues/2349
implementation("com.google.dagger:hilt-android:2.48.1")
kapt("com.google.dagger:hilt-android-compiler:2.48.1")
implementation("androidx.hilt:hilt-navigation-fragment:1.0.0")
kapt("androidx.hilt:hilt-compiler:1.0.0")

Expand All @@ -233,7 +234,7 @@ dependencies {

// firebase
// https://firebase.google.com/docs/android/setup
implementation(platform("com.google.firebase:firebase-bom:32.1.1"))
implementation(platform("com.google.firebase:firebase-bom:32.4.0"))
implementation("com.google.firebase:firebase-analytics-ktx")
implementation("com.google.firebase:firebase-crashlytics-ktx")
implementation("com.google.firebase:firebase-messaging-ktx")
Expand All @@ -251,12 +252,12 @@ dependencies {

// unit test
testImplementation("junit:junit:4.13.2")
testImplementation("org.mockito:mockito-core:5.4.0")
testImplementation("org.mockito:mockito-core:5.6.0")
// testImplementation("org.mockito:mockito-inline:3.3.3")
testImplementation("io.mockk:mockk:1.13.5")
testImplementation("io.mockk:mockk:1.13.8")
testImplementation("androidx.arch.core:core-testing:2.2.0")
testImplementation("com.squareup.okhttp3:mockwebserver:5.0.0-alpha.2")
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0")
testImplementation("com.squareup.okhttp3:mockwebserver:5.0.0-alpha.11")
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.10")
// testImplementation("org.robolectric:robolectric:4.3")

/**
Expand Down Expand Up @@ -380,47 +381,47 @@ dependencies {
// implementation("androidx.compose:compose-bom:2023.04.00")
// androidTestImplementation("androidx.compose:compose-bom:2023.04.00")
// Foundation (Border, Background, Box, Image, Scroll, shapes, animations, etc.)
implementation("androidx.compose.foundation:foundation:1.4.3")
implementation("androidx.compose.foundation:foundation:1.5.4")
// or Material Design 2
implementation("androidx.compose.material:material:1.4.3")
implementation("androidx.compose.material:material:1.5.4")
// Material Design 3
implementation("androidx.compose.material3:material3:1.1.1")
implementation("androidx.compose.material3:material3:1.1.2")
// Android Studio Preview support
implementation("androidx.compose.ui:ui-tooling-preview:1.4.3")
debugImplementation("androidx.compose.ui:ui-tooling:1.4.3")
implementation("androidx.compose.ui:ui-tooling-preview:1.5.4")
debugImplementation("androidx.compose.ui:ui-tooling:1.5.4")
// UI Tests
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.4.3")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.4.3")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.5.4")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.5.4")
// Animations
implementation("androidx.compose.animation:animation:1.4.3")
implementation("androidx.compose.animation:animation:1.5.4")
// Constraint layout
implementation("androidx.constraintlayout:constraintlayout-compose:1.0.1")
// Optional - Included automatically by material, only add when you need
// the icons but not the material library (e.g. when using Material3 or a
// custom design system based on Foundation)
// implementation("androidx.compose.material:material-icons-core")
// Optional - Add full set of material icons
implementation("androidx.compose.material:material-icons-extended:1.4.3")
implementation("androidx.compose.material:material-icons-extended:1.5.4")
// Optional - Add window size utils
implementation("androidx.compose.material3:material3-window-size-class:1.1.1")
implementation("androidx.compose.material3:material3-window-size-class:1.1.2")
// Optional - Integration with activities
implementation("androidx.activity:activity-compose:1.7.2")
implementation("androidx.activity:activity-compose:1.8.0")
// Optional - Integration with ViewModels
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2")
// Optional - Integration with LiveData
// implementation("androidx.compose.runtime:runtime-livedata:1.4.3")
// Lifecycle utilities for Compose
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.6.1")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.6.2")
// navigation
implementation("androidx.navigation:navigation-compose:2.6.0")
implementation("androidx.navigation:navigation-compose:2.7.4")
implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
// https://github.com/skydoves/landscapist
// implementation("com.github.skydoves:landscape-bom:2.1.7")
implementation("com.github.skydoves:landscapist-glide:2.2.2")
implementation("com.github.skydoves:landscapist-placeholder:2.2.2")
implementation("com.github.skydoves:landscapist-glide:2.2.10")
implementation("com.github.skydoves:landscapist-placeholder:2.2.10")
// https://google.github.io/accompanist/
// https://github.com/google/accompanist
val accompanistVersion = "0.28.0"
val accompanistVersion = "0.32.0"
implementation("com.google.accompanist:accompanist-systemuicontroller:$accompanistVersion")
implementation("com.google.accompanist:accompanist-pager:$accompanistVersion")
implementation("com.google.accompanist:accompanist-permissions:$accompanistVersion")
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
</intent-filter>
</activity>

<activity
android:name=".compose.ComposeActivity"
android:configChanges="orientation|screenSize"
android:exported="false"
android:theme="@style/Theme.MyApplication.NoActionBar" />

<activity
android:name=".ui.screen.permission.PermissionActivity"
android:exported="false">
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/com/example/moviedb/ui/base/BaseActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract class BaseActivity<ViewBinding : ViewDataBinding, ViewModel : BaseViewM
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.uiState.collectLatest { uiState ->
handleLoading(uiState.isLoading)
handleLoading(isLoading = uiState.isLoading)
handleError(errorType = uiState.errorType)
}
}
Expand Down Expand Up @@ -206,13 +206,15 @@ abstract class BaseActivity<ViewBinding : ViewDataBinding, ViewModel : BaseViewM
}

fun showForceUpdateDialog() {
showDialog(
val forceUpdateDialog = showDialog(
title = getString(R.string.force_update_app),
dismissListener = {
isShowHighPriorityDialog = false
}
)
isShowHighPriorityDialog = true
if (forceUpdateDialog != null) {
isShowHighPriorityDialog = true
}
}

/**
Expand Down Expand Up @@ -271,7 +273,7 @@ abstract class BaseActivity<ViewBinding : ViewDataBinding, ViewModel : BaseViewM
}*/

fun dismissShowingDialog() {
if (showingDialog?.isShowing == true) {
if (isShowHighPriorityDialog.not() && showingDialog?.isShowing == true) {
showingDialog?.dismiss()
showingDialog = null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract class BaseBottomSheetDialogFragment<ViewBinding : ViewDataBinding, View
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.uiState.collectLatest { uiState ->
handleLoading(uiState.isLoading)
handleLoading(isLoading = uiState.isLoading)
handleError(errorType = uiState.errorType)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ abstract class BaseDialogFragment<ViewBinding : ViewDataBinding, ViewModel : Bas
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.uiState.collectLatest { uiState ->
handleLoading(uiState.isLoading)
handleLoading(isLoading = uiState.isLoading)
handleError(errorType = uiState.errorType)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract class BaseFragment<ViewBinding : ViewDataBinding, ViewModel : BaseViewM
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.uiState.collectLatest { uiState ->
handleLoading(uiState.isLoading)
handleLoading(isLoading = uiState.isLoading)
handleError(errorType = uiState.errorType)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.example.moviedb.ui.base

import android.view.LayoutInflater
import android.view.ViewGroup
import android.view.animation.AnimationUtils
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.paging.PagingDataAdapter
Expand All @@ -11,7 +10,6 @@ import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.example.moviedb.BR
import com.example.moviedb.R
import java.util.concurrent.Executors

private interface BaseRecyclerAdapter<Item : Any, ViewBinding : ViewDataBinding> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import kotlinx.coroutines.plus
import timber.log.Timber
import java.net.ConnectException
import java.net.HttpURLConnection
import java.net.SocketTimeoutException
Expand Down Expand Up @@ -37,6 +38,7 @@ open class BaseViewModel : ViewModel() {
* handle throwable when load fail
*/
protected fun toErrorType(throwable: Throwable): ErrorType {
Timber.e("toErrorType: ${throwable.printStackTrace()}")
return when (throwable) {
// case no internet connection
is UnknownHostException -> {
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/example/moviedb/ui/base/UiState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ data class UiState(
)

sealed class ErrorType {
object NoInternetConnection : ErrorType()
object ConnectTimeout : ErrorType()
object ForceUpdateApp : ErrorType()
object UnAuthorized : ErrorType()
object ServerMaintain : ErrorType()
data object NoInternetConnection : ErrorType()
data object ConnectTimeout : ErrorType()
data object ForceUpdateApp : ErrorType()
data object UnAuthorized : ErrorType()
data object ServerMaintain : ErrorType()
class UnknownError(val throwable: Throwable) : ErrorType()
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.example.moviedb.ui.base.BaseFragment
import com.example.moviedb.ui.base.BaseListAdapter
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import timber.log.Timber

abstract class ItemsFragment<ViewBinding : ViewDataBinding, ViewModel : ItemsViewModel<Item>, Item : Any> :
BaseFragment<ViewBinding, ViewModel>() {
Expand Down Expand Up @@ -43,6 +44,7 @@ abstract class ItemsFragment<ViewBinding : ViewDataBinding, ViewModel : ItemsVie
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.itemsUiState.collectLatest { uiState ->
Timber.d("uiState collectLatest $uiState")
swipeRefreshLayout.isRefreshing = uiState.isRefreshing
handleLoading(isLoading = uiState.isLoading)
listAdapter.submitList(uiState.items)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ class ImageFragment : BaseFragment<FragmentImageBinding, BaseViewModel>() {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
startPostponedEnterTransition()
return false
}

override fun onResourceReady(
resource: Drawable?,
model: Any?,
resource: Drawable,
model: Any,
target: Target<Drawable>?,
dataSource: DataSource?,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
startPostponedEnterTransition()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ class SplashFragment : BaseFragment<FragmentSplashBinding, BaseViewModel>() {

private fun navigateToHome() {
getNavController()?.navigate(
when (1) {
when (2) {
0 -> SplashFragmentDirections.toMovieListPager()
1 -> SplashFragmentDirections.toPopularMovie()
2 -> SplashFragmentDirections.toComposeActivity()
else -> SplashFragmentDirections.toPagingMovie()
}
)
Expand Down
Loading

0 comments on commit df499b8

Please sign in to comment.