Skip to content

Instantly share code, notes, and snippets.

@halcyonmobiledev
halcyonmobiledev / observable-extension.txt
Last active October 2, 2021 18:09
Data Binding observables and Kotlin
// with just a simple extension function for the Data Binding ObservableField
inline fun <R> ObservableField<R>.observe(crossinline callback: (R) -> Unit) {
this.addOnPropertyChangedCallback(object : Observable.OnPropertyChangedCallback() {
override fun onPropertyChanged(p0: Observable?, p1: Int) {
callback(get())
}
})
}
...
@halcyonmobiledev
halcyonmobiledev / BindingViewModelAdapter.kt
Created December 10, 2017 11:35
Abstract RecyclerView adapter which uses DataBinding & MVVM pattern to bind data to each view item
/*
* Copyright (c) 2017 Halcyon Mobile
* http://www.halcyonmobile.com
* All rights reserved.
*/
import android.databinding.DataBindingUtil
import android.databinding.OnRebindCallback
import android.databinding.ViewDataBinding
import android.support.annotation.CallSuper
import android.support.annotation.LayoutRes
/*
* Copyright (c) 2017 Halcyon Mobile
* http://www.halcyonmobile.com
* All rights reserved.
*/
import android.arch.lifecycle.LifecycleOwner
import android.arch.lifecycle.MutableLiveData
import android.arch.lifecycle.Observer
import android.support.annotation.MainThread
@halcyonmobiledev
halcyonmobiledev / detekt-config.yml
Created October 8, 2019 08:43
Config file for Detekt
autoCorrect: true
failFast: false
test-pattern: # Configure exclusions for test sources
active: true
patterns: # Test file regexes
- '.*/test/.*'
- '.*Test.kt'
- '.*Spec.kt'
exclude-rule-sets:
@halcyonmobiledev
halcyonmobiledev / FastFile
Created October 8, 2019 08:56
Fastlane config file
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins