$ show Kotlin/anko
This is the Anko library for Android, a Kotlin DSL that provides type-safe builders for UI layouts, SQLite queries, intents, dialogs, async tasks, logging, and other common Android patterns. The repository additionally contains a code generator (using ASM to parse Android SDK classes) that produces extension functions for views, properties, listeners, and services per API level, and an IntelliJ/Android Studio plugin that includes XML-to-Anko conversion, live preview of DSL layouts, and refactoring intentions. The library is officially deprecated (see GOODBYE.md) in favor of Jetpack Compose, Splitties, and Android KTX; the last commit was in 2019. The codebase is well-structured overall, but the generated files are massive and repetitive, and the library has not kept pace with the Android ecosystem (e.g., still uses android.support libraries, GlobalScope for coroutines, and targets SDK versions up to 28). Reusable components include the static commons (Logging, Async, Intents, AlertBuilder), the code generator's class tree and rendering pipeline, and the SQLite query builders.
The LLM identified 5 files worth highlighting for reuse:
Provides `doAsync`, `runOnUiThread`, `uiThread` and other async utilities that wrap Android threads with Kotlin coroutines. Demonstrates a clean, reusable pattern for background task execution and UI thread posting, with a `Result` type for handling outcomes. Could be extracted as a standalone utility library.
Defines the `AnkoLogger` interface with extension functions for log levels (verbose, debug, info, warn, error, wtf). Uses a minimal, non-intrusive approach to add logging to any class. The pattern of tagging log messages with the class name can be reused in any Android project.
Implements a type-safe, fluent query builder for SQLite select statements. Supports `whereArgs`, `orderBy`, `groupBy`, `having`, `limit`, and custom row parsers (`RowParser`, `MapRowParser`). The `parseSingle` and `parseList` methods execute the query and map results. This pattern is reusable across any SQLite-based Android app.
Builds a hierarchical class tree from Android SDK classes using ASM bytecode analysis. Captures methods, constructors, fields, and supertype relationships. This is the core of Anko's code generator and demonstrates a reusable pattern for generating Kotlin DSL APIs from any Java/SDK library. Could be adapted for other wrapper generators.
Provides a DSL builder for Android AlertDialogs with support for title, message, positive/negative/neutral buttons, custom views, and list/choice selectors. The builder pattern with receiver lambdas (`alert { ... }`) is a clean, reusable approach to dialog construction. Includes coroutine-based callbacks in the appcompat-v7 variant.