Skip to content

Instantly share code, notes, and snippets.

@Ghedeon
Ghedeon / NestedCoordinatorLayout.kt
Created August 21, 2018 21:02
NestedCoordinatorLayout
import android.annotation.SuppressLint
import android.content.Context
import android.support.annotation.AttrRes
import android.support.design.widget.CoordinatorLayout
import android.support.v4.view.NestedScrollingChild2
import android.support.v4.view.NestedScrollingChildHelper
import android.util.AttributeSet
import android.view.View
import com.douglas.startpage.R
{
"meta": {
"theme": "macchiato"
},
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"basics": {
"name": "Richard Hendriks",
"label": "Programmer",
"image": "",
"email": "richard.hendriks@mail.com",
@Ghedeon
Ghedeon / README.md
Last active June 26, 2020 05:26
Screenshot & Recorder

1. Screenshot

Description (no more than one connected device):

  1. Sets device in demo mode: hides your notifications, fixed clock, full battery, wifi level)
  2. Takes a screenshot and saves it into captures directory. Also to your clipboard, so it's ready for Paste
  3. Exits demo mode

Usage:

  1. Download screenshot.sh
  2. chmod +x screenshot.sh
@Ghedeon
Ghedeon / Example.kt
Created December 25, 2019 11:58
Multitype RecyclerView Adapter
recycler_view.withBindings {
+DateBinding()
+IncomingMessageBinding()
+OutgoingMessageBinding()
}
recycler_view.submitList(listOf<Widget.State>(...))
//**************************************************************//
class DateBinding : ItemBinding<DateWidget.State, DateWidget> {
@Ghedeon
Ghedeon / filter_devices.groovy
Created July 22, 2015 12:40
Android Gradle (1.3.0-beta4). Filter multiple devices
project.afterEvaluate {
project.("connectedDebugAndroidTest").doFirst {
def originalProvider = deviceProvider
deviceProvider = [
getName : { originalProvider.getName() },
init : { originalProvider.init() },
terminate : { originalProvider.terminate() },
getDevices : { filterDevices(originalProvider.getDevices()) },
getTimeoutInMs: { originalProvider.getTimeoutInMs() },
isConfigured : { originalProvider.isConfigured() },
@Ghedeon
Ghedeon / NotNull.kt
Created March 4, 2019 15:23
NotNull delegate with lazy message
fun <T: Any> notNull(lazyMessage: () -> Any): ReadWriteProperty<Any?, T> = NotNullVar(lazyMessage)
private class NotNullVar<T: Any>(val lazyMessage: () -> Any) : ReadWriteProperty<Any?, T> {
private var value: T? = null
override fun getValue(thisRef: Any?, property: KProperty<*>): T {
return value ?: throw IllegalStateException(lazyMessage.toString())
}
override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
@Ghedeon
Ghedeon / Test.kt
Created February 1, 2019 18:58
Coroutine Test
class AccountOwnerTypeViewModelTest {
@Rule
@JvmField
val rule = InstantTaskExecutorRule()
val mainThreadSurrogate = newSingleThreadContext("UI thread")
@Before
fun setUp() {
@Ghedeon
Ghedeon / NoSwipeabaleViewPager.kt
Last active November 3, 2018 22:20
A ViewPager with disabled swipe.
import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.KeyEvent
import android.view.MotionEvent
import androidx.viewpager.widget.ViewPager
class NoSwipeabaleViewPager @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : ViewPager(context, attrs) {
@SuppressLint("ClickableViewAccessibility")
@Ghedeon
Ghedeon / HideBottomViewOnScrollBehavior.kt
Last active September 27, 2018 11:53
HideBottomViewOnScrollBehavior that ensures BottomView visibility
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.TimeInterpolator
import android.content.Context
import android.support.design.animation.AnimationUtils
import android.support.design.widget.CoordinatorLayout
import android.support.design.widget.Snackbar
import android.support.v4.view.ViewCompat
import android.support.v7.widget.RecyclerView
import android.util.AttributeSet
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "test.co.vv.myapplication"
minSdkVersion 15
targetSdkVersion 21