diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b17f294..411df4a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -47,27 +47,27 @@ tasks { } ktlint { - version.set("0.37.1") + version.set("0.38.1") disabledRules.set(setOf("import-ordering")) } dependencies { - val lifecycleVersion = "2.3.0-alpha04" - val roomVersion = "2.3.0-alpha01" - val okHttpVersion = "4.7.2" + val lifecycleVersion = "2.3.0-alpha07" + val roomVersion = "2.3.0-alpha02" + val okHttpVersion = "4.8.1" val retrofitVersion = "2.9.0" - val moshiVersion = "1.9.2" - val daggerVersion = "2.27" + val moshiVersion = "1.10.0" + val daggerVersion = "2.28.3" implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.0") - implementation("androidx.core:core:1.3.1") - implementation("androidx.appcompat:appcompat:1.3.0-alpha01") - implementation("androidx.activity:activity-ktx:1.2.0-alpha07") - implementation("androidx.fragment:fragment-ktx:1.3.0-alpha07") + implementation("androidx.core:core-ktx:1.5.0-alpha02") + implementation("androidx.appcompat:appcompat:1.3.0-alpha02") + implementation("androidx.activity:activity-ktx:1.2.0-alpha08") + implementation("androidx.fragment:fragment-ktx:1.3.0-alpha08") implementation("com.google.android.material:material:1.3.0-alpha02") - implementation("androidx.constraintlayout:constraintlayout:1.1.3") + implementation("androidx.constraintlayout:constraintlayout:2.0.1") implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") implementation("androidx.recyclerview:recyclerview:1.2.0-alpha05") implementation("androidx.annotation:annotation:1.1.0") @@ -77,7 +77,7 @@ dependencies { implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion") implementation("androidx.preference:preference:1.1.1") implementation("androidx.emoji:emoji-bundled:1.1.0") - implementation("androidx.paging:paging-runtime-ktx:3.0.0-alpha04") + implementation("androidx.paging:paging-runtime-ktx:3.0.0-alpha05") implementation("androidx.viewpager2:viewpager2:1.0.0") implementation("androidx.room:room-ktx:$roomVersion") @@ -101,7 +101,7 @@ dependencies { implementation("me.relex:circleindicator:2.1.4") - implementation("io.coil-kt:coil:0.11.0") + implementation("io.coil-kt:coil:1.0.0-rc2") implementation("com.github.connyduck:sparkbutton:4.0.0") diff --git a/app/src/main/kotlin/at/connyduck/pixelcat/components/bottomsheet/accountselection/AccountSelectionAdapter.kt b/app/src/main/kotlin/at/connyduck/pixelcat/components/bottomsheet/accountselection/AccountSelectionAdapter.kt index d5d1824..a366ea2 100644 --- a/app/src/main/kotlin/at/connyduck/pixelcat/components/bottomsheet/accountselection/AccountSelectionAdapter.kt +++ b/app/src/main/kotlin/at/connyduck/pixelcat/components/bottomsheet/accountselection/AccountSelectionAdapter.kt @@ -28,7 +28,7 @@ import at.connyduck.pixelcat.components.util.extension.hide import at.connyduck.pixelcat.components.util.extension.show import at.connyduck.pixelcat.databinding.ItemAccountSelectionBinding import at.connyduck.pixelcat.db.entitity.AccountEntity -import coil.api.load +import coil.load import coil.transform.RoundedCornersTransformation class AccountSelectionAdapter( diff --git a/app/src/main/kotlin/at/connyduck/pixelcat/components/compose/ComposeImageAdapter.kt b/app/src/main/kotlin/at/connyduck/pixelcat/components/compose/ComposeImageAdapter.kt index 63136a2..c7a1d08 100644 --- a/app/src/main/kotlin/at/connyduck/pixelcat/components/compose/ComposeImageAdapter.kt +++ b/app/src/main/kotlin/at/connyduck/pixelcat/components/compose/ComposeImageAdapter.kt @@ -28,7 +28,7 @@ import at.connyduck.pixelcat.R import at.connyduck.pixelcat.components.util.BindingHolder import at.connyduck.pixelcat.databinding.ItemComposeImageBinding import at.connyduck.sparkbutton.helpers.Utils -import coil.api.load +import coil.load import java.io.File interface OnImageActionClickListener { diff --git a/app/src/main/kotlin/at/connyduck/pixelcat/components/profile/ProfileHeaderAdapter.kt b/app/src/main/kotlin/at/connyduck/pixelcat/components/profile/ProfileHeaderAdapter.kt index e0e0993..ab9d707 100644 --- a/app/src/main/kotlin/at/connyduck/pixelcat/components/profile/ProfileHeaderAdapter.kt +++ b/app/src/main/kotlin/at/connyduck/pixelcat/components/profile/ProfileHeaderAdapter.kt @@ -28,7 +28,7 @@ import at.connyduck.pixelcat.components.util.extension.visible import at.connyduck.pixelcat.databinding.ItemProfileHeaderBinding import at.connyduck.pixelcat.model.Account import at.connyduck.pixelcat.model.Relationship -import coil.api.load +import coil.load import coil.transform.RoundedCornersTransformation import java.text.NumberFormat diff --git a/app/src/main/kotlin/at/connyduck/pixelcat/components/profile/ProfileImageAdapter.kt b/app/src/main/kotlin/at/connyduck/pixelcat/components/profile/ProfileImageAdapter.kt index 6be9b7f..b2362ec 100644 --- a/app/src/main/kotlin/at/connyduck/pixelcat/components/profile/ProfileImageAdapter.kt +++ b/app/src/main/kotlin/at/connyduck/pixelcat/components/profile/ProfileImageAdapter.kt @@ -30,7 +30,7 @@ import at.connyduck.pixelcat.components.util.extension.show import at.connyduck.pixelcat.databinding.ItemProfileImageBinding import at.connyduck.pixelcat.model.Attachment import at.connyduck.pixelcat.model.Status -import coil.api.load +import coil.load class ProfileImageAdapter( private val imageSizePx: Int diff --git a/app/src/main/kotlin/at/connyduck/pixelcat/components/timeline/TimelineImageAdapter.kt b/app/src/main/kotlin/at/connyduck/pixelcat/components/timeline/TimelineImageAdapter.kt index 07a45ee..78978ee 100644 --- a/app/src/main/kotlin/at/connyduck/pixelcat/components/timeline/TimelineImageAdapter.kt +++ b/app/src/main/kotlin/at/connyduck/pixelcat/components/timeline/TimelineImageAdapter.kt @@ -25,7 +25,7 @@ import androidx.recyclerview.widget.RecyclerView import at.connyduck.pixelcat.components.util.BindingHolder import at.connyduck.pixelcat.databinding.ItemTimelineImageBinding import at.connyduck.pixelcat.model.Attachment -import coil.api.load +import coil.load class TimelineImageAdapter : RecyclerView.Adapter>() { diff --git a/app/src/main/kotlin/at/connyduck/pixelcat/components/timeline/TimelineListAdapter.kt b/app/src/main/kotlin/at/connyduck/pixelcat/components/timeline/TimelineListAdapter.kt index 71471d6..9a97e0d 100644 --- a/app/src/main/kotlin/at/connyduck/pixelcat/components/timeline/TimelineListAdapter.kt +++ b/app/src/main/kotlin/at/connyduck/pixelcat/components/timeline/TimelineListAdapter.kt @@ -29,7 +29,7 @@ import at.connyduck.pixelcat.components.util.BindingHolder import at.connyduck.pixelcat.components.util.extension.visible import at.connyduck.pixelcat.databinding.ItemStatusBinding import at.connyduck.pixelcat.db.entitity.StatusEntity -import coil.api.load +import coil.load import coil.transform.RoundedCornersTransformation import java.text.DateFormat import java.text.SimpleDateFormat @@ -85,7 +85,7 @@ fun BindingHolder.bind(status: StatusEntity, displayWidth: In } else { it.meta.small.height.toFloat() / it.meta.small.width.toFloat() } - }.max()?.coerceAtMost(1f) ?: 1f + }.maxOrNull()?.coerceAtMost(1f) ?: 1f binding.postImages.layoutParams.height = (displayWidth * maxImageRatio).toInt() diff --git a/app/src/main/kotlin/at/connyduck/pixelcat/components/timeline/detail/DetailReplyAdapter.kt b/app/src/main/kotlin/at/connyduck/pixelcat/components/timeline/detail/DetailReplyAdapter.kt index 5242af9..c8548d4 100644 --- a/app/src/main/kotlin/at/connyduck/pixelcat/components/timeline/detail/DetailReplyAdapter.kt +++ b/app/src/main/kotlin/at/connyduck/pixelcat/components/timeline/detail/DetailReplyAdapter.kt @@ -9,7 +9,7 @@ import at.connyduck.pixelcat.components.timeline.TimelineDiffUtil import at.connyduck.pixelcat.components.util.BindingHolder import at.connyduck.pixelcat.databinding.ItemReplyBinding import at.connyduck.pixelcat.db.entitity.StatusEntity -import coil.api.load +import coil.load import coil.transform.RoundedCornersTransformation import java.text.SimpleDateFormat diff --git a/app/src/main/kotlin/at/connyduck/pixelcat/network/calladapter/NetworkResponseCall.kt b/app/src/main/kotlin/at/connyduck/pixelcat/network/calladapter/NetworkResponseCall.kt index a035371..7a6731c 100644 --- a/app/src/main/kotlin/at/connyduck/pixelcat/network/calladapter/NetworkResponseCall.kt +++ b/app/src/main/kotlin/at/connyduck/pixelcat/network/calladapter/NetworkResponseCall.kt @@ -32,19 +32,32 @@ internal class NetworkResponseCall( ) : Call> { override fun enqueue(callback: Callback>) { - return delegate.enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { - val body = response.body() + return delegate.enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + val body = response.body() - val errorbody = response.errorBody()?.string() - if (response.isSuccessful) { - if (body != null) { - callback.onResponse( - this@NetworkResponseCall, - Response.success(NetworkResponse.Success(body)) - ) + val errorbody = response.errorBody()?.string() + if (response.isSuccessful) { + if (body != null) { + callback.onResponse( + this@NetworkResponseCall, + Response.success(NetworkResponse.Success(body)) + ) + } else { + // Response is successful but the body is null + callback.onResponse( + this@NetworkResponseCall, + Response.success( + NetworkResponse.Failure( + NetworkResponseError.ApiError( + response.code() + ) + ) + ) + ) + } } else { - // Response is successful but the body is null callback.onResponse( this@NetworkResponseCall, Response.success( @@ -56,33 +69,22 @@ internal class NetworkResponseCall( ) ) } - } else { - callback.onResponse( - this@NetworkResponseCall, - Response.success( - NetworkResponse.Failure( - NetworkResponseError.ApiError( - response.code() - ) + } + + override fun onFailure(call: Call, throwable: Throwable) { + Log.d("NetworkResponseCall", "Network response failed", throwable) + val networkResponse = when (throwable) { + is IOException -> NetworkResponse.Failure( + NetworkResponseError.NetworkError( + throwable ) ) - ) + else -> NetworkResponse.Failure(NetworkResponseError.UnknownError(throwable)) + } + callback.onResponse(this@NetworkResponseCall, Response.success(networkResponse)) } } - - override fun onFailure(call: Call, throwable: Throwable) { - Log.d("NetworkResponseCall", "Network response failed", throwable) - val networkResponse = when (throwable) { - is IOException -> NetworkResponse.Failure( - NetworkResponseError.NetworkError( - throwable - ) - ) - else -> NetworkResponse.Failure(NetworkResponseError.UnknownError(throwable)) - } - callback.onResponse(this@NetworkResponseCall, Response.success(networkResponse)) - } - }) + ) } override fun isExecuted() = delegate.isExecuted diff --git a/app/src/main/kotlin/at/connyduck/pixelcat/util/ViewBindingExtensions.kt b/app/src/main/kotlin/at/connyduck/pixelcat/util/ViewBindingExtensions.kt index ecf7eaf..3cdd332 100644 --- a/app/src/main/kotlin/at/connyduck/pixelcat/util/ViewBindingExtensions.kt +++ b/app/src/main/kotlin/at/connyduck/pixelcat/util/ViewBindingExtensions.kt @@ -28,20 +28,24 @@ class FragmentViewBindingDelegate( private var binding: T? = null init { - fragment.lifecycle.addObserver(object : DefaultLifecycleObserver { - override fun onCreate(owner: LifecycleOwner) { - fragment.viewLifecycleOwnerLiveData.observe( - fragment, - { t -> - t?.lifecycle?.addObserver(object : DefaultLifecycleObserver { - override fun onDestroy(owner: LifecycleOwner) { - binding = null - } - }) - } - ) + fragment.lifecycle.addObserver( + object : DefaultLifecycleObserver { + override fun onCreate(owner: LifecycleOwner) { + fragment.viewLifecycleOwnerLiveData.observe( + fragment, + { t -> + t?.lifecycle?.addObserver( + object : DefaultLifecycleObserver { + override fun onDestroy(owner: LifecycleOwner) { + binding = null + } + } + ) + } + ) + } } - }) + ) } override fun getValue(thisRef: Fragment, property: KProperty<*>): T {