Skip to content

Instantly share code, notes, and snippets.

View justintuchek's full-sized avatar

Justin Tuchek justintuchek

View GitHub Profile
public class RxInteropFunction<T, R> implements Func1<T, R>, Function<T, R> {
public static <T, R> RxInteropFunction<T, R> wrap(Function<T, R> function) {
return new RxInteropFunction<>(function);
}
private final Function<T, R> function;
private RxInteropFunction(Function<T, R> function) {
this.function = function;
@justintuchek
justintuchek / PlugInRadioPage.java
Last active September 3, 2017 15:47
Expressive Espresso
import com.botlink.app.R;
import com.botlink.app.util.widget.ImageViewTest;
import com.botlink.app.util.widget.TextViewTest;
public class PlugInRadioPage {
public PlugInRadioPage checkImage(@DrawableRes int id) {
ImageViewTest.withId(R.id.iv_plug_in_radio_image)
.displayed()
.src(id);
@justintuchek
justintuchek / AlternativeBoolean.java
Created March 16, 2017 17:41
A politically empowered type!
public enum AlternativeBoolean {
TRUE(Boolean.TRUE),
FALSE(Boolean.TRUE);
private Boolean realAnswer;
AlternativeBoolean(Boolean realAnswer) {
this.realAnswer = realAnswer;
}
@justintuchek
justintuchek / License.txt
Last active December 22, 2016 19:27
A safer way to loosely obtain Android String resources by name (instead of id.)
The MIT License (MIT)
Copyright (c) 2016 DJI
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE O
@justintuchek
justintuchek / StringResolver.java
Last active December 8, 2016 15:02
A safer way to loosely obtain Android String resources by name (instead of id.)
package com.botlink.stringresourceresolver;
import android.content.Context;
public final class StringResolver {
/**
* Value returned from {@link android.content.res.Resources#getIdentifier(String, String, String)}
* when resource name does not yield a valid resource id.
/**
* This is a wrapper around the original component to transform
* interactions from their original callback style to a more
* reactive approach.
**/
public final class DJICameraKit {
private final Camera component;
@Override
@justintuchek
justintuchek / BehaviorTransformer.java
Last active October 20, 2016 13:58
A behavioral transformer for observables! All inspiration from Retrofit's mock network behavior configurations.
public final class BehaviorTransformer {
private final Random random = new Random();
private long delayMs = 2000;
private int variancePercent = 40;
private int errorCode = 1337;
private int failurePercent = 3;
package com.company.util;
public interface IndexValue<Source, Value> {
Value get(Source source);
}
public enum Access {
PUBLIC,
PROTECTED,
PACKAGE,
PRIVATE
}
public class MMInputUtils {
private MMInputUtils() {
throw new AssertionError("no instances");
}
@IntDef({CURSOR_POSITION_BEGINNING, CURSOR_POSITION_ENDING})
@Retention(RetentionPolicy.SOURCE)
public @interface CursorPosition{}