Skip to content

Commit

Permalink
Lint, public 기능 명시적 리턴타입 기입
Browse files Browse the repository at this point in the history
  • Loading branch information
Pluu committed May 15, 2023
1 parent 28cc1b2 commit 3539091
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ChromeCustomTabsNavigator(
private val context: Context
) : Navigator<ChromeCustomTabsNavigator.Destination>() {

override fun createDestination() = Destination(this)
override fun createDestination(): Destination = Destination(this)

override fun navigate(
destination: Destination,
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PreferenceState<T>(
private val onValueChange: (receiver: PreferenceState<T>, 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<ImageBitmap?> = remember(initValues) { mutableStateOf(init()) }

@Composable
inline fun rememberDrawable(
initValues: Drawable? = null,
crossinline init: @DisallowComposableCalls () -> Drawable?
) = remember(initValues) { mutableStateOf(init()) }
): MutableState<Drawable?> = remember(initValues) { mutableStateOf(init()) }
2 changes: 1 addition & 1 deletion core-android/src/main/java/com/pluu/utils/ContextExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.core.os.bundleOf

inline fun <reified T : Activity> Context.buildIntent(
vararg argument: Pair<String, Any?>
) = Intent(this, T::class.java).apply {
): Intent = Intent(this, T::class.java).apply {
putExtras(bundleOf(*argument))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Intent> =
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<Intent> =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { activityResult ->
if (activityResult.resultCode == Activity.RESULT_OK) {
callback(activityResult)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion core/src/main/java/com/pluu/webtoon/model/NAV_ITEM.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ enum class NAV_ITEM {
KAKAOPAGE;

companion object {
fun getDefault() = NAVER
fun getDefault(): NAV_ITEM = NAVER
}
}
2 changes: 1 addition & 1 deletion core/src/main/java/com/pluu/webtoon/model/Result.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sealed class Result<out R> {
/**
* `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 <T> Result<T>.successOr(fallback: T): T {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Intent> =
rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) { activityResult ->
if (activityResult.resultCode == Activity.RESULT_OK) {
callback(activityResult)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion model/src/main/java/com/pluu/webtoon/model/ToonInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ data class ToonInfoWithFavorite(
val info: ToonInfo,
val isFavorite: Boolean = false
) : Serializable {
val id = info.id
val id: String = info.id
}

0 comments on commit 3539091

Please sign in to comment.