Originally published on https://github.com/m-rec/c325017f9e66db9320f99fdced6ac3d66abc9212
Coroutines documents
- Getting started guide
- The Kotlin Playground allows to try out things
- The kotlinx.coroutines guide is the (huge!) reference
- Everything from Roman Elizarov including
- Structured concurrency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Open a new android project in Android Studio | |
| # From Android Studio, run the gradle task ":properties" | |
| # From the command-line, run | |
| $ ./gradlew :properties | |
| # Check if you see this message | |
| Starting a Gradle Daemon, 1 incompatible could not be reused | |
| # To debug the problem run this | |
| $ ps auxw | grep GradleDaemon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // buildSrc/src/main/kotlin/Config.kt | |
| object Config { | |
| const val ACTIVITY = "com.mautinoa.cardapp.MainActivity" | |
| const val PACKAGE = "com.mautinoa.cardapp" | |
| const val kotlinVersion = "1.2.71" | |
| object SdkVersions { | |
| val versionCode = 1 | |
| val compile = 28 | |
| val target = 26 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // buildSrc/src/main/java/GooglePlay.kt | |
| import java.io.File | |
| object GooglePlay { | |
| @JvmStatic | |
| fun updateWhatsNew(projectDir: File, version: String) { | |
| val files: List<File> = listOf( | |
| "src/production/play/en-US/listing/whatsnew-alpha", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun app() = AppComponent.instance | |
| interface AppComponent { | |
| val context: Context | |
| val retrofit: Retrofit | |
| val okHttpClient: OkHttpClient | |
| val catRepository: CatRepository | |
| val catService: CatService | |
| val mainThreadScheduler: Scheduler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class Producer<out T : Beverage>( | |
| val beverage: T | |
| ) { | |
| fun produce() : T = beverage | |
| } | |
| class Consumer<in T: Beverage> { | |
| fun consume(t: T) = println("Thanks for the drink $t!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://medium.com/@garnop/safe-concise-text-parsing-with-regex-destructuring-in-kotlin-b8f77ef1e30c | |
| fun parsePhoneNumber(input: String): PhoneNumber { | |
| val invalids = input.filterNot { it in '0'..'9' || it == '-' } | |
| require(invalids.isEmpty()) { "Input $input has invalid characters : $invalids" } | |
| val (areaCode, prefix, lineNumber) = input.split("-").map(String::toInt) | |
| return PhoneNumber(areaCode, prefix, lineNumber) | |
| } | |
| fun main(args: Array<String>) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lolcat() { | |
| FILE="$HOME/.config/androidpackage.txt" | |
| echo "Reading ${FILE}" | |
| export PACKAGE=$( cat ${FILE} ) | |
| adb devices | |
| echo pidcat $1 $2 $PACKAGE | |
| sleep 2 | |
| pidcat $1 $2 $PACKAGE | |
| } |
Add the printProperties task to your build.gradle
Run from both the command-line and intellij the gradle task printProperties
> Task :printProperties
Detecting what could cause incompatible gradle daemons
Run './gradlew printProperties' from the command-line and the same task Android studio
See https://docs.gradle.org/4.5/userguide/build_environment.html
See https://docs.gradle.org/4.5/userguide/gradle_daemon.html#daemon_faq