Skip to content

Instantly share code, notes, and snippets.

View SaurabhSandav's full-sized avatar

Saurabh Sandav SaurabhSandav

  • Mumbai, India
View GitHub Profile
@chris-hatton
chris-hatton / DataSizeFormatter.kt
Last active May 11, 2025 15:09
Human Readable Data Size Formatter for Kotlin Multiplatform (uses Common API only)
package datasizeformatter
import kotlin.math.abs
import kotlin.math.pow
import kotlin.math.roundToLong
/**
* Format a human-readable representation of data size, in binary base form.
* e.g. 1024 -> 1 KiB
* @param byteCount The number of bytes to represent in human-readable form. `Long.MIN_VALUE` is unsupported.

Build "Sources for Android 29" so you can comfortably browse the Android API source in Android Studio.

  1. Collect source files
mkdir android-sdk-source-build
cd android-sdk-source-build

mkdir -p frameworks/base