Improve: Android Studio's Reformat

This commit is contained in:
LooKeR
2021-11-16 01:12:52 +05:30
parent e49b357173
commit a321e9bfa5
32 changed files with 91 additions and 80 deletions

View File

@ -30,7 +30,7 @@ class IndexHandler(private val repositoryId: Long, private val callback: Callbac
interface Callback {
fun onRepository(
mirrors: List<String>, name: String, description: String,
certificate: String, version: Int, timestamp: Long
certificate: String, version: Int, timestamp: Long,
)
fun onProduct(product: Product)
@ -181,7 +181,7 @@ class IndexHandler(private val repositoryId: Long, private val callback: Callbac
uri: String,
localName: String,
qName: String,
attributes: Attributes
attributes: Attributes,
) {
super.startElement(uri, localName, qName, attributes)

View File

@ -16,7 +16,7 @@ object IndexV1Parser {
name: String,
description: String,
version: Int,
timestamp: Long
timestamp: Long,
)
fun onProduct(product: Product)
@ -26,17 +26,17 @@ object IndexV1Parser {
private class Screenshots(
val phone: List<String>,
val smallTablet: List<String>,
val largeTablet: List<String>
val largeTablet: List<String>,
)
private class Localized(
val name: String, val summary: String, val description: String,
val whatsNew: String, val metadataIcon: String, val screenshots: Screenshots?
val whatsNew: String, val metadataIcon: String, val screenshots: Screenshots?,
)
private fun <T> Map<String, Localized>.getAndCall(
key: String,
callback: (String, Localized) -> T?
callback: (String, Localized) -> T?,
): T? {
return this[key]?.let { callback(key, it) }
}
@ -50,7 +50,7 @@ object IndexV1Parser {
private fun Map<String, Localized>.findString(
fallback: String,
callback: (Localized) -> String
callback: (Localized) -> String,
): String {
return (find { _, localized -> callback(localized).nullIfEmpty() } ?: fallback).trim()
}

View File

@ -32,7 +32,7 @@ object RepositoryUpdater {
private enum class IndexType(
val jarName: String,
val contentName: String,
val certificateFromIndex: Boolean
val certificateFromIndex: Boolean,
) {
INDEX("index.jar", "index.xml", true),
INDEX_V1("index-v1.jar", "index-v1.json", false)
@ -93,7 +93,7 @@ object RepositoryUpdater {
fun update(
context: Context,
repository: Repository, unstable: Boolean,
callback: (Stage, Long, Long?) -> Unit
callback: (Stage, Long, Long?) -> Unit,
): Single<Boolean> {
return update(
context,
@ -107,7 +107,7 @@ object RepositoryUpdater {
private fun update(
context: Context,
repository: Repository, indexTypes: List<IndexType>, unstable: Boolean,
callback: (Stage, Long, Long?) -> Unit
callback: (Stage, Long, Long?) -> Unit,
): Single<Boolean> {
val indexType = indexTypes[0]
return downloadIndex(context, repository, indexType, callback)
@ -152,7 +152,7 @@ object RepositoryUpdater {
private fun downloadIndex(
context: Context,
repository: Repository, indexType: IndexType,
callback: (Stage, Long, Long?) -> Unit
callback: (Stage, Long, Long?) -> Unit,
): Single<Pair<Downloader.Result, File>> {
return Single.just(Unit)
.map { Cache.getTemporaryFile(context) }
@ -190,7 +190,7 @@ object RepositoryUpdater {
private fun processFile(
context: Context,
repository: Repository, indexType: IndexType, unstable: Boolean,
file: File, lastModified: String, entityTag: String, callback: (Stage, Long, Long?) -> Unit
file: File, lastModified: String, entityTag: String, callback: (Stage, Long, Long?) -> Unit,
): Boolean {
var rollback = true
return synchronized(updaterLock) {
@ -216,7 +216,7 @@ object RepositoryUpdater {
IndexHandler(repository.id, object : IndexHandler.Callback {
override fun onRepository(
mirrors: List<String>, name: String, description: String,
certificate: String, version: Int, timestamp: Long
certificate: String, version: Int, timestamp: Long,
) {
changedRepository = repository.update(
mirrors, name, description, version,
@ -278,7 +278,7 @@ object RepositoryUpdater {
name: String,
description: String,
version: Int,
timestamp: Long
timestamp: Long,
) {
changedRepository = repository.update(
mirrors, name, description, version,
@ -299,7 +299,7 @@ object RepositoryUpdater {
override fun onReleases(
packageName: String,
releases: List<Release>
releases: List<Release>,
) {
if (Thread.interrupted()) {
throw InterruptedException()
@ -432,7 +432,7 @@ object RepositoryUpdater {
private fun transformProduct(
product: Product,
features: Set<String>,
unstable: Boolean
unstable: Boolean,
): Product {
val releasePairs =
product.releases.distinctBy { it.identifier }.sortedByDescending { it.versionCode }