Skip to content

Instantly share code, notes, and snippets.

View PaulWoitaschek's full-sized avatar

Paul Woitaschek PaulWoitaschek

View GitHub Profile
// IntelliJ API Decompiler stub source generated from a class file
// Implementation of methods is not available
package com.afollestad.materialdialogs;
/**
* @deprecated
*/
public class MaterialDialogCompat {
N4Igzghgbgpg0jAniAXCAwgJgPoAZO4gA0IA5hALYwCSAdgJYAu9EANvQF4wAmqjATgFcYJRoP60AcoIoAjGP1QAOAOwqlATiUkAZv0oxpchagCMAFkxLcANgCsGkgHcA9v1bcAggGNmsVDpsYCIgru68KKBhHugwtIwKABqomHY25na4qgB0ahqYAMwOBc5uMXEJ/ACaKZYaNgXq2TY2KhoOqjYksqwu3gDWAMoAFvQ6jOgurKjmGlqOID19Q6PjAEouTjNzGqYAviTcgrSkMC60YKgA2qBHJ2e01BEgs3NK2K/1xCDc9GDeLlg/B4fCEIW8rBgEGBEQEwhIEKhMIAKuJaGYlKZ1CoSMFvOIQSg4eCIGBGJCAAribzDUmE4m4mD44GTMkzXC4Q7HU7nSQGVAgZHDGAAAkGVFYrEQIop9El0O+dx5tGRiAADjAZiRIbBWJNjowzAdbtyHk8BZ93p9zIq/gCgfSwQjIdDHfCQIjXdxURJUJlMGpGcy3SSyZTqbTgrCneAmQTWYaUCoOVz7rz+WghaKAOL8egUEUAEVN50VJZV6s1KC6IB1MD1LgNqBsxp+5fNaEyHJwnxstv+gIUIedSOHHpdKLRftMc05seD0fd3lJ5JgVP4NLpi5CePjLjZSYKc6VDz5VAFWZF6HEUZFAFlzlMmMMy2mKxrUDjazBdfr4qgClbE9zg7EAuw5bBwJtQ47UHGFQSXCcx09SdfRQepcAWXd4KJGNlzDNcIy3BCdzjFl90TGdj3LM8q0FYUi2hfoRWRFw5FfZVVQ/FBtG/X9G3/asgPbZ5wPecC+xggcHW3EcvRIuTUPRFBGlwFRzC/bDkJXcMN0jMctITADcFMai31oi8GIACRkehuCvaAmGQVNOMrFJtR/es/0TQCiBNN9QPA3BII5fB+3tIdZPHUcopQngfWUhw7HMIMCVinTCL04jcPdQyKLMGwzOVCzMwYjZGASWgWOOWh60uFyHi4qs5zrBsmxU4SAtE0LzA+HZMHCuDkKQ2K
@PaulWoitaschek
PaulWoitaschek / racecondition.java
Created April 2, 2016 12:17
Demonstrates .share() race condition
Observable<Integer> bomb = Observable.range(1, 1000000)
.share();
bomb.observeOn(Schedulers.io())
.reduce((first, second) -> first + second)
.subscribe(System.out::println);
bomb.observeOn(Schedulers.io())
.reduce((first, second) -> first + second)
.subscribe(System.out::println);
@PaulWoitaschek
PaulWoitaschek / tm.xml
Created September 29, 2016 08:28
TM - logm IntelliJ life template for Timber
<template name="tm" value="timber.log.Timber.d($content$);" description="Log method name and its arguments" toReformat="true" toShortenFQNames="true">
<variable name="content" expression="groovyScript(&quot;def params = _2.collect {it + ' = [%s]'}.join(', '); return '\&quot;' + _1 + '() called' + (params.empty ? '' : ' with: ' + params + ',') + '\&quot;' + (_2.empty ? '' : ','+_2.join(','))&quot;, methodName(), methodParameters()) " defaultValue="" alwaysStopAt="false" />
<context>
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
@PaulWoitaschek
PaulWoitaschek / selector.kt
Last active December 2, 2018 20:06
Comparable selector
import java.util.*
import kotlin.comparisons.compareValuesBy
/**
* Demonstration of how the compare selectors could be moved to the companion object to prevent object allocations.
* Else each call to compareTo would create n new objects
*
* @author Paul Woitaschek
*/
class Foo(val a: String, val b: Int, val c: Date) : Comparable<Foo> {
@PaulWoitaschek
PaulWoitaschek / sample.java
Created February 6, 2017 08:23
Kotlin interop failue
//////////////// java base class
public final class GenericInterop {
public interface BaseChanger<From, To> {
Base<To> change(Base<From> from);
}
public static class Base<T> {
@PaulWoitaschek
PaulWoitaschek / ActivityModule.kt
Last active April 13, 2017 12:15
Activity Composition
/**
* A module that can be used to abstract logic from the activity
*
* @author Paul Woitaschek
*/
@Suppress("UNUSED_PARAMETER")
abstract class ActivityModule {
lateinit var activity: CompositionActivity
@PaulWoitaschek
PaulWoitaschek / ControllerArgumentDelegate.kt
Last active July 28, 2017 06:43
Controller Argument Delegation. An extensible mechanism for seriaizing values to the Controllers bundle.
/**
* An abstract argument delegate that uses the property to infer the key name for the bundle.
*/
abstract class ControllerArgumentDelegate<T : Any> : ReadWriteProperty<Controller, T> {
private var value: T? = null
override final fun getValue(thisRef: Controller, property: KProperty<*>): T {
if (value == null) {
val key = property.name
import android.os.Parcel
import android.os.Parcelable
import org.assertj.core.api.Assertions.assertThat
/**
* A test for parcelable implementations
*/
class ParcelTester<T : Parcelable>(klazz: Class<T>) {
// access the creator through reflection like android does
@PaulWoitaschek
PaulWoitaschek / layout.xml
Created October 13, 2017 08:10
CL Bug 1.1.0-beta3
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="@+id/red"
android:layout_width="0dp"