Skip to content

Instantly share code, notes, and snippets.

@koral--
koral-- / VersionCodes.java
Created November 24, 2016 15:30
VersionCodes
public static void foo() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
long x = JobInfo.getMinPeriodMillis(); //available on N+, no lint error
} else {
long x = JobInfo.getMinPeriodMillis(); //available on M-, lint error
}
if (isNougatOrAbove()) {
long x = JobInfo.getMinPeriodMillis(); //available on N+, no lint error
} else {
long x = JobInfo.getMinPeriodMillis(); //available on M-, lint check does not work!
import com.android.ddmlib.AndroidDebugBridge
import com.android.ddmlib.IDevice
import com.android.ddmlib.NullOutputReceiver
import java.util.concurrent.TimeUnit
buildscript {
repositories {
jcenter()
}
@koral--
koral-- / bitrise.yml
Last active July 23, 2017 23:22
Bitrise workflow with Open STF
---
format_version: '2'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: android
workflows:
stf_test:
steps:
- activate-ssh-key:
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
- cache-pull: {}
import java.io.File
val file = File("/dev/null")
println("exists: ${file.exists()}")
println("isFile: ${file.isFile()}")
println("isDirectory: ${file.isDirectory()}")
@koral--
koral-- / app_build.gradle
Last active September 19, 2017 18:52
app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion versions.compileSdk
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "pl.droidsonroids.bootcamp.rxbootcamp"
minSdkVersion 21
@koral--
koral-- / tooManyOpenFiles.kts
Last active September 21, 2017 23:13
Too many open files
package pl.droidsonroids.edgetest
import android.content.res.AssetFileDescriptor
import android.support.test.InstrumentationRegistry
import org.junit.Assert
import org.junit.Test
class TooManyOpenFilesTest {
//asset named "test" required
@Test
@koral--
koral-- / readAfterDeletion.kts
Created September 25, 2017 12:01
readAfterDeletion created by koral - https://repl.it/L91G/0
import java.io.BufferedReader
import java.io.File
import java.io.FileReader
val file = File("test")
file.writeText("this is file content")
BufferedReader(FileReader(file)).use {
println("deleted?: ${file.delete()}")
println("content?: ${it.readLine()}")
@koral--
koral-- / build.gradle
Created October 9, 2017 01:25
Pseudolocalization in Android project
buildTypes {
debug {
pseudoLocalesEnabled true
}
}
@koral--
koral-- / build.gradle
Last active October 15, 2017 15:32
Resources filtering
android {
defaultConfig {
//other locales will be filtered out
resConfigs 'en', 'hu'
}
buildTypes {
debug {
pseudoLocalesEnabled true
}
}