From 35390919dd578003a67a375ff5e1a50d8a82193d Mon Sep 17 00:00:00 2001 From: pluu Date: Tue, 16 May 2023 00:26:54 +0900 Subject: [PATCH] =?UTF-8?q?Lint,=20public=20=EA=B8=B0=EB=8A=A5=20=EB=AA=85?= =?UTF-8?q?=EC=8B=9C=EC=A0=81=20=EB=A6=AC=ED=84=B4=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EA=B8=B0=EC=9E=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customtabs/ChromeCustomTabsNavigator.kt | 4 ++-- .../pluu/compose/ambient/PreferenceAmbient.kt | 10 +++++----- .../com/pluu/compose/foundation/Background.kt | 2 +- .../compose/preference/remeberPreference.kt | 2 +- .../pluu/compose/ui/graphics/ImageAsset.kt | 5 +++-- .../main/java/com/pluu/utils/ContextExt.kt | 2 +- .../java/com/pluu/utils/ContextExtends.kt | 2 +- .../utils/result/ActivityResultContracts.kt | 20 +++++++++++-------- .../pluu/utils/result/FragmentResultOwner.kt | 4 ++-- .../java/com/pluu/webtoon/model/NAV_ITEM.kt | 2 +- .../java/com/pluu/webtoon/model/Result.kt | 2 +- .../ui/compose/ActivityResultContracts.kt | 4 +++- .../pluu/webtoon/ui/compose/WebToonSetup.kt | 2 +- .../com/pluu/webtoon/utils/ImageViewExt.kt | 2 +- .../java/com/pluu/webtoon/model/ToonInfo.kt | 2 +- 15 files changed, 36 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/com/pluu/webtoon/navigation/customtabs/ChromeCustomTabsNavigator.kt b/app/src/main/java/com/pluu/webtoon/navigation/customtabs/ChromeCustomTabsNavigator.kt index ae8f6ba9..2133373a 100644 --- a/app/src/main/java/com/pluu/webtoon/navigation/customtabs/ChromeCustomTabsNavigator.kt +++ b/app/src/main/java/com/pluu/webtoon/navigation/customtabs/ChromeCustomTabsNavigator.kt @@ -22,7 +22,7 @@ class ChromeCustomTabsNavigator( private val context: Context ) : Navigator() { - override fun createDestination() = Destination(this) + override fun createDestination(): Destination = Destination(this) override fun navigate( destination: Destination, @@ -42,7 +42,7 @@ class ChromeCustomTabsNavigator( return null // Do not add to the back stack, managed by Chrome Custom Tabs } - override fun popBackStack() = true // Managed by Chrome Custom Tabs + override fun popBackStack(): Boolean = true // Managed by Chrome Custom Tabs private fun CustomTabsIntent.Builder.buildCustomTabsIntent( extras: Extras diff --git a/compose/src/main/java/com/pluu/compose/ambient/PreferenceAmbient.kt b/compose/src/main/java/com/pluu/compose/ambient/PreferenceAmbient.kt index ec3190ea..697f6aec 100644 --- a/compose/src/main/java/com/pluu/compose/ambient/PreferenceAmbient.kt +++ b/compose/src/main/java/com/pluu/compose/ambient/PreferenceAmbient.kt @@ -30,27 +30,27 @@ class PreferenceCompose( fun getValue( key: String, defaultValue: Boolean = false - ) = preferences.getBoolean(key, defaultValue) + ): Boolean = preferences.getBoolean(key, defaultValue) fun getValue( key: String, defaultValue: String = "" - ) = preferences.getString(key, defaultValue)!! + ): String = preferences.getString(key, defaultValue)!! fun getValue( key: String, defaultValue: Float = 0f - ) = preferences.getFloat(key, defaultValue) + ): Float = preferences.getFloat(key, defaultValue) fun getValue( key: String, defaultValue: Int = 0 - ) = preferences.getInt(key, defaultValue) + ): Int = preferences.getInt(key, defaultValue) fun getValue( key: String, defaultValue: Long = 0L - ) = preferences.getLong(key, defaultValue) + ): Long = preferences.getLong(key, defaultValue) fun getValue( key: String, diff --git a/compose/src/main/java/com/pluu/compose/foundation/Background.kt b/compose/src/main/java/com/pluu/compose/foundation/Background.kt index 215ab054..df7107c1 100644 --- a/compose/src/main/java/com/pluu/compose/foundation/Background.kt +++ b/compose/src/main/java/com/pluu/compose/foundation/Background.kt @@ -9,7 +9,7 @@ import androidx.compose.ui.unit.Dp fun Modifier.backgroundCorner( color: Color, size: Dp -) = this.then( +): Modifier = this.then( background( color = color, shape = RoundedCornerShape(size) diff --git a/compose/src/main/java/com/pluu/compose/preference/remeberPreference.kt b/compose/src/main/java/com/pluu/compose/preference/remeberPreference.kt index 6296629e..d9e8b96c 100644 --- a/compose/src/main/java/com/pluu/compose/preference/remeberPreference.kt +++ b/compose/src/main/java/com/pluu/compose/preference/remeberPreference.kt @@ -15,7 +15,7 @@ class PreferenceState( private val onValueChange: (receiver: PreferenceState, item: T) -> Unit ) { private var entryValue by mutableStateOf(initialValue) - var summary by mutableStateOf(initialSummary) + var summary: String by mutableStateOf(initialSummary) fun updateEntryValue(value: T) { preferences.edit { diff --git a/compose/src/main/java/com/pluu/compose/ui/graphics/ImageAsset.kt b/compose/src/main/java/com/pluu/compose/ui/graphics/ImageAsset.kt index f63a6711..816d9d3b 100644 --- a/compose/src/main/java/com/pluu/compose/ui/graphics/ImageAsset.kt +++ b/compose/src/main/java/com/pluu/compose/ui/graphics/ImageAsset.kt @@ -3,6 +3,7 @@ package com.pluu.compose.ui.graphics import android.graphics.drawable.Drawable import androidx.compose.runtime.Composable import androidx.compose.runtime.DisallowComposableCalls +import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.graphics.ImageBitmap @@ -11,10 +12,10 @@ import androidx.compose.ui.graphics.ImageBitmap inline fun rememberImageAsset( initValues: ImageBitmap? = null, crossinline init: @DisallowComposableCalls () -> ImageBitmap? -) = remember(initValues) { mutableStateOf(init()) } +): MutableState = remember(initValues) { mutableStateOf(init()) } @Composable inline fun rememberDrawable( initValues: Drawable? = null, crossinline init: @DisallowComposableCalls () -> Drawable? -) = remember(initValues) { mutableStateOf(init()) } +): MutableState = remember(initValues) { mutableStateOf(init()) } diff --git a/core-android/src/main/java/com/pluu/utils/ContextExt.kt b/core-android/src/main/java/com/pluu/utils/ContextExt.kt index 89a1a488..1eb6f4cc 100644 --- a/core-android/src/main/java/com/pluu/utils/ContextExt.kt +++ b/core-android/src/main/java/com/pluu/utils/ContextExt.kt @@ -7,7 +7,7 @@ import androidx.core.os.bundleOf inline fun Context.buildIntent( vararg argument: Pair -) = Intent(this, T::class.java).apply { +): Intent = Intent(this, T::class.java).apply { putExtras(bundleOf(*argument)) } diff --git a/core-android/src/main/java/com/pluu/utils/ContextExtends.kt b/core-android/src/main/java/com/pluu/utils/ContextExtends.kt index 4d800293..699dfc5f 100644 --- a/core-android/src/main/java/com/pluu/utils/ContextExtends.kt +++ b/core-android/src/main/java/com/pluu/utils/ContextExtends.kt @@ -7,7 +7,7 @@ import androidx.annotation.StringRes import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment -fun Context.getCompatColor(@ColorRes resId: Int) = ContextCompat.getColor(this, resId) +fun Context.getCompatColor(@ColorRes resId: Int): Int = ContextCompat.getColor(this, resId) fun Context.toast(@StringRes resId: Int, duration: Int = Toast.LENGTH_SHORT) { toast(getString(resId), duration) diff --git a/core-android/src/main/java/com/pluu/utils/result/ActivityResultContracts.kt b/core-android/src/main/java/com/pluu/utils/result/ActivityResultContracts.kt index aed1ff9f..c5f44b6f 100644 --- a/core-android/src/main/java/com/pluu/utils/result/ActivityResultContracts.kt +++ b/core-android/src/main/java/com/pluu/utils/result/ActivityResultContracts.kt @@ -1,23 +1,27 @@ package com.pluu.utils.result import android.app.Activity +import android.content.Intent import androidx.activity.ComponentActivity import androidx.activity.result.ActivityResult +import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts import androidx.fragment.app.Fragment inline fun ComponentActivity.registerForActivityResult( crossinline callback: (ActivityResult) -> Unit -) = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { activityResult -> - if (activityResult.resultCode == Activity.RESULT_OK) { - callback(activityResult) +): ActivityResultLauncher = + registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { activityResult -> + if (activityResult.resultCode == Activity.RESULT_OK) { + callback(activityResult) + } } -} inline fun Fragment.registerForActivityResult( crossinline callback: (ActivityResult) -> Unit -) = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { activityResult -> - if (activityResult.resultCode == Activity.RESULT_OK) { - callback(activityResult) +): ActivityResultLauncher = + registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { activityResult -> + if (activityResult.resultCode == Activity.RESULT_OK) { + callback(activityResult) + } } -} diff --git a/core-android/src/main/java/com/pluu/utils/result/FragmentResultOwner.kt b/core-android/src/main/java/com/pluu/utils/result/FragmentResultOwner.kt index c6595327..41003995 100644 --- a/core-android/src/main/java/com/pluu/utils/result/FragmentResultOwner.kt +++ b/core-android/src/main/java/com/pluu/utils/result/FragmentResultOwner.kt @@ -16,10 +16,10 @@ fun FragmentActivity.setFragmentResultListener( fun FragmentActivity.setFragmentResult( requestKey: String, result: Bundle = Bundle() -) = supportFragmentManager.setFragmentResult(requestKey, result) +): Unit = supportFragmentManager.setFragmentResult(requestKey, result) fun Fragment.setFragmentResult( requestKey: String, result: Bundle = Bundle() -) = parentFragmentManager.setFragmentResult(requestKey, result) +): Unit = parentFragmentManager.setFragmentResult(requestKey, result) diff --git a/core/src/main/java/com/pluu/webtoon/model/NAV_ITEM.kt b/core/src/main/java/com/pluu/webtoon/model/NAV_ITEM.kt index f4f4f96b..6362e970 100644 --- a/core/src/main/java/com/pluu/webtoon/model/NAV_ITEM.kt +++ b/core/src/main/java/com/pluu/webtoon/model/NAV_ITEM.kt @@ -8,6 +8,6 @@ enum class NAV_ITEM { KAKAOPAGE; companion object { - fun getDefault() = NAVER + fun getDefault(): NAV_ITEM = NAVER } } diff --git a/core/src/main/java/com/pluu/webtoon/model/Result.kt b/core/src/main/java/com/pluu/webtoon/model/Result.kt index 2c4c4fca..52f8fa32 100644 --- a/core/src/main/java/com/pluu/webtoon/model/Result.kt +++ b/core/src/main/java/com/pluu/webtoon/model/Result.kt @@ -16,7 +16,7 @@ sealed class Result { /** * `true` if [Result] is of type [Success] & holds non-null [Success.data]. */ -val Result<*>.succeeded +val Result<*>.succeeded: Boolean get() = this is Result.Success && data != null fun Result.successOr(fallback: T): T { diff --git a/features/ui-common/src/main/java/com/pluu/webtoon/ui/compose/ActivityResultContracts.kt b/features/ui-common/src/main/java/com/pluu/webtoon/ui/compose/ActivityResultContracts.kt index 53265706..af33ee17 100644 --- a/features/ui-common/src/main/java/com/pluu/webtoon/ui/compose/ActivityResultContracts.kt +++ b/features/ui-common/src/main/java/com/pluu/webtoon/ui/compose/ActivityResultContracts.kt @@ -1,15 +1,17 @@ package com.pluu.webtoon.ui.compose import android.app.Activity +import android.content.Intent import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.ActivityResult +import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.runtime.Composable @Composable inline fun rememberLauncherForActivityResult( crossinline callback: (ActivityResult) -> Unit -) = +): ActivityResultLauncher = rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) { activityResult -> if (activityResult.resultCode == Activity.RESULT_OK) { callback(activityResult) diff --git a/features/ui-common/src/main/java/com/pluu/webtoon/ui/compose/WebToonSetup.kt b/features/ui-common/src/main/java/com/pluu/webtoon/ui/compose/WebToonSetup.kt index 97f0612c..9d4e8b4b 100644 --- a/features/ui-common/src/main/java/com/pluu/webtoon/ui/compose/WebToonSetup.kt +++ b/features/ui-common/src/main/java/com/pluu/webtoon/ui/compose/WebToonSetup.kt @@ -13,7 +13,7 @@ import com.pluu.webtoon.ui.compose.theme.AppTheme fun Fragment.fragmentComposeView( parent: CompositionContext? = null, content: @Composable () -> Unit -) = ComposeView(requireContext()).apply { +): ComposeView = ComposeView(requireContext()).apply { setParentCompositionContext(parent) layoutParams = ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, diff --git a/features/ui-common/src/main/java/com/pluu/webtoon/utils/ImageViewExt.kt b/features/ui-common/src/main/java/com/pluu/webtoon/utils/ImageViewExt.kt index 25031723..318d4d89 100644 --- a/features/ui-common/src/main/java/com/pluu/webtoon/utils/ImageViewExt.kt +++ b/features/ui-common/src/main/java/com/pluu/webtoon/utils/ImageViewExt.kt @@ -5,6 +5,6 @@ import coil.request.ImageRequest const val userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1" -fun ImageRequest.Builder.applyAgent() = apply { +fun ImageRequest.Builder.applyAgent(): ImageRequest.Builder = apply { addHeader("User-Agent", userAgent) } diff --git a/model/src/main/java/com/pluu/webtoon/model/ToonInfo.kt b/model/src/main/java/com/pluu/webtoon/model/ToonInfo.kt index 3db775ec..700c4836 100644 --- a/model/src/main/java/com/pluu/webtoon/model/ToonInfo.kt +++ b/model/src/main/java/com/pluu/webtoon/model/ToonInfo.kt @@ -18,5 +18,5 @@ data class ToonInfoWithFavorite( val info: ToonInfo, val isFavorite: Boolean = false ) : Serializable { - val id = info.id + val id: String = info.id }