Материалы к докладу на митап red_mad_robot 15.12.2022
- Наш кодстайл Kotlin
- EditorConfig - шарим настройки форматирования между всеми разработчиками
/** Wrapper over the given [list] for Compose to mark this list as [Immutable]. */ | |
@Immutable | |
@JvmInline | |
value class ImmutableList<T>(private val list: List<T>) : List<T> by list | |
/** Returns empty list marked as [Immutable]. */ | |
inline fun <T> immutableListOf(): ImmutableList<T> = ImmutableList(emptyList()) | |
/** Returns a new [Immutable] list of given [elements]. */ |
package com.example.build | |
import org.gradle.api.DefaultTask | |
import org.gradle.api.file.RegularFileProperty | |
import org.gradle.api.tasks.InputFile | |
import org.gradle.api.tasks.OutputFile | |
import org.gradle.api.tasks.TaskAction | |
/** Adds `android:debuggable="true"` to the manifest. */ | |
abstract class MakeDebuggableTask : DefaultTask() { |
Материалы к докладу на митап red_mad_robot 15.12.2022
import androidx.datastore.core.DataStore | |
import androidx.datastore.core.Serializer | |
import kotlinx.coroutines.flow.first | |
import kotlinx.serialization.json.Json | |
import kotlinx.serialization.json.decodeFromStream | |
import kotlinx.serialization.json.encodeToStream | |
import java.io.InputStream | |
import java.io.OutputStream | |
/** |
package io.example | |
import kotlinx.serialization.Serializable | |
import kotlinx.serialization.json.Json | |
import kotlinx.serialization.json.decodeFromStream | |
import okhttp3.Interceptor | |
import okhttp3.Response | |
import retrofit2.HttpException | |
import retrofit2.Invocation | |
import java.io.IOException |
#!/usr/bin/env bash | |
# | |
# Script for APK and AAB signing. | |
# | |
# Usage: ./sign-app.sh <format> <path_to_app> <keystore_base64> <properties_base64> | |
# | |
# format - should be one of: apk or aab | |
# path_to_app - path to apk/aab file or '--auto' to automatically detect path | |
# keystore_base64 - Base64 encoded keystore file | |
# properties_base64 - Base64 encoded properties file. This file should contain: |
import android.annotation.SuppressLint | |
import android.content.Context | |
import android.graphics.Canvas | |
import android.util.AttributeSet | |
import android.view.View | |
import com.airbnb.epoxy.ModelView | |
/** | |
* Вьюха-якорь, которая нужна чтобы в зафиксировать положение скролла в `RecyclerView`. | |
* |
#!/usr/bin/env bash | |
set -euo pipefail | |
function extract_float_field() { | |
field=$1 | |
ioreg -rw0 -c AppleSmartBattery | | |
grep BatteryData | | |
sed -E "s/.*\"$field\"=([0-9]+).*/\1/" | | |
xargs -I % lldb --batch --source-quietly --one-line "print/f %" | # Convert IEEE-754 float |
import androidx.datastore.core.DataStore | |
import androidx.datastore.core.Serializer | |
import java.io.InputStream | |
import java.io.OutputStream | |
abstract class NullableSerializer<T : Any> : Serializer<T?> { | |
override val defaultValue: T? = null | |
final override suspend fun readFrom(input: InputStream): T? { |