Skip to content

Instantly share code, notes, and snippets.

View alorma's full-sized avatar
🤡

Bernat Borrás Paronella alorma

🤡
View GitHub Profile
#!/bin/sh
# Check if device is connected
if [[ $(adb get-state) ]]; then
# Run Android and jUnit tests
./gradlew clean testDebug connectedDebugAndroidTest
else
# Run jUnit tests
./gradlew clean testDebug
fi
#!/bin/sh
./gradlew clean testDebug
#!/bin/sh
# Your code belongs here
cd .git/
cd hooks/
class DelayedTimeProvider(private val timeProvider: TimeProvider,
private val delayed: Delayed) : TimeProvider {
override fun getTime(): Long = timeProvider.getTime() + delayed.get()
}
data class Delayed(private val time: Long, private val unit: TimeUnit) {
fun get() = unit.toMillis(time)
}
class CreateTriggerPresenter @Inject constructor(
private val permissionRequest: DexterBuilder.SinglePermissionListener,
private val androidGetContact: AndroidGetContact,
val logger: Logger)
: BasePresenter<CreateTriggerState, CreateTriggerRoute, CreateTriggerAction, CreateTriggerView>(logger) {
override fun action(action: CreateTriggerAction) {
when (action) {
is RequestContactAction -> onContactRequest()
is ContactImportAction -> onContactImport(action)
fun configureRxThreading() {
RxJavaPlugins.reset()
val immediate = object : Scheduler() {
override fun scheduleDirect(run: Runnable, delay: Long, unit: TimeUnit): Disposable {
return super.scheduleDirect(run, 0, unit)
}
override fun createWorker(): Worker {
return ExecutorScheduler.ExecutorWorker(Executor { it.run() })
@alorma
alorma / CalendarDsl.kt
Last active February 8, 2018 16:33
Kotlin calendar DSL
import java.util.*
@DslMarker
annotation class CalendarDsl
@CalendarDsl
class CalendarBuilder(val calendar: Calendar) {
fun dayOfMonth(function: () -> Int) = calendar.apply { set(Calendar.DAY_OF_MONTH, function()) }
fun dayOfMonth(value: Int) = calendar.apply { set(Calendar.DAY_OF_MONTH, value) }
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.inputmethod.InputMethodManager;
import java.util.HashMap;