Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plugin org.jmailen.kotlinter to v4.4.0 #1565

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions app/src/main/java/com/jerboa/JerboaAppState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ import java.nio.charset.StandardCharsets
fun rememberJerboaAppState(
coroutineScope: CoroutineScope = rememberCoroutineScope(),
navController: NavHostController = rememberNavController(),
): JerboaAppState {
return remember(
): JerboaAppState =
remember(
navController,
coroutineScope,
) {
Expand All @@ -58,7 +58,6 @@ fun rememberJerboaAppState(
coroutineScope,
)
}
}

@Stable
class JerboaAppState(
Expand Down Expand Up @@ -326,24 +325,23 @@ class JerboaAppState(
LaunchedEffect(key) {
val savedStateHandle = navController.previousBackStackEntry?.savedStateHandle
if (savedStateHandle?.contains(key) == true) {
savedStateHandle.get<String>(key)
savedStateHandle
.get<String>(key)
?.let { Json.decodeFromString<T>(it) }
?.also(consumeBlock)
}
}
}
}

inline fun <reified T> getKotlinxSerializerSaver(): Saver<T, String> {
return Saver(
inline fun <reified T> getKotlinxSerializerSaver(): Saver<T, String> =
Saver(
save = { Json.encodeToString(it) },
restore = { Json.decodeFromString<T>(it) },
)
}

inline fun <reified T> getKotlinxSerializerSaver3(): Saver<T?, String> {
return Saver(
inline fun <reified T> getKotlinxSerializerSaver3(): Saver<T?, String> =
Saver(
save = { Json.encodeToString(it) },
restore = { Json.decodeFromString<T>(it) },
)
}
19 changes: 11 additions & 8 deletions app/src/main/java/com/jerboa/JerboaApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import com.jerboa.api.API
import com.jerboa.db.AppDBContainer
import com.jerboa.util.downloadprogress.DownloadProgress

class JerboaApplication : Application(), ImageLoaderFactory {
class JerboaApplication :
Application(),
ImageLoaderFactory {
lateinit var container: AppDBContainer
lateinit var imageViewerLoader: ImageLoader
private lateinit var imageLoader: ImageLoader
Expand All @@ -23,31 +25,32 @@ class JerboaApplication : Application(), ImageLoaderFactory {

container = AppDBContainer(this)
imageLoader =
ImageLoader.Builder(this)
ImageLoader
.Builder(this)
.okHttpClient(API.httpClient)
.crossfade(true)
.error(R.drawable.error_placeholder)
.placeholder(R.drawable.ic_launcher_foreground)
.components {
add(SvgDecoder.Factory())
add(VideoFrameDecoder.Factory())
}
.build()
}.build()

imageGifLoader =
imageLoader.newBuilder()
imageLoader
.newBuilder()
.components {
add(SvgDecoder.Factory())
if (Build.VERSION.SDK_INT >= 28) {
add(ImageDecoderDecoder.Factory())
} else {
add(GifDecoder.Factory())
}
}
.build()
}.build()

imageViewerLoader =
imageGifLoader.newBuilder()
imageGifLoader
.newBuilder()
.okHttpClient(DownloadProgress.downloadProgressHttpClient)
.build()
}
Expand Down
Loading