Skip to content

Instantly share code, notes, and snippets.

@mr-archano
mr-archano / InjectableActivityTestRule.kt
Created Mar 9, 2019 — forked from rharter/InjectableActivityTestRule.kt
Test Rule that allows you to use Dagger Android's automatic lifecycle based injection without making your Application class `open`, or overriding it in tests.
View InjectableActivityTestRule.kt
package com.pixite.pigment.testing
import android.app.Activity
import android.app.Application
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager
@mr-archano
mr-archano / build.gradle
Created Feb 26, 2018
Conditionally apply plugin
View build.gradle
apply plugin: 'com.novoda.build-properties'
buildProperties {
local {
file rootProject.file('local.properties')
}
}
apply from: file('utilities.gradle')
@mr-archano
mr-archano / pull_request_template.md
Last active Jan 17, 2017
Pull request template
View pull_request_template.md

Tracked in JIRA by XXX

Scope of the PR

What have you tried to solve? Be short, but insightful.

Considerations/Implementation Details

Give enough context to reviewers and specify focus of the changes.

@mr-archano
mr-archano / EspressoTestRule.java
Created Nov 6, 2016 — forked from patrickhammond/EspressoTestRule.java
Hacking through Espresso issues...
View EspressoTestRule.java
import android.app.Activity;
import android.app.Instrumentation;
import android.app.KeyguardManager;
import android.app.KeyguardManager.KeyguardLock;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.support.test.InstrumentationRegistry;
View CachingObservableReplayer.java
import java.util.concurrent.atomic.AtomicReference;
import rx.Observable;
import rx.functions.Action1;
import rx.functions.Func0;
class CachingObservableReplayer<T> implements Observable.Transformer<T, T> {
private final AtomicReference<Observable<T>> pendingObservable;
@mr-archano
mr-archano / Oauth1SigningInterceptor.java
Created Sep 11, 2016 — forked from serj-lotutovici/Oauth1SigningInterceptor.java
An OkHttp interceptor which does OAuth1 signing. Requires Java 7 (but can easily be ported to Java 6).
View Oauth1SigningInterceptor.java
/*
* Copyright (C) 2015 Jake Wharton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View SubscribedObservableReplayer.java
import rx.Observable;
import rx.functions.Action0;
import rx.functions.Func0;
import java.util.concurrent.atomic.AtomicReference;
class SubscribedObservableReplayer<T> implements Observable.Transformer<T, T> {
private final AtomicReference<Observable<T>> pendingObservable;
View PendingObservableReplayer.java
import java.util.concurrent.atomic.AtomicReference;
import rx.Observable;
import rx.Subscriber;
import rx.functions.Action0;
import rx.functions.Func0;
/**
* This custom {@link Observable.Transformer} can be used to replay an in flight {@link Observable}
* source among all {@link Subscriber}s subscribed before its termination.
*/
@mr-archano
mr-archano / screenrecord.sh
Created Apr 17, 2016 — forked from tasomaniac/screenrecord.sh
Screen Record for Android
View screenrecord.sh
#!/bin/sh
set -e
if [ -z "$1" ]; then
shot_path=$(date +%Y-%m-%d-%H-%M-%S).mp4
else
shot_path="$*"
fi
@mr-archano
mr-archano / RxponetialBackoff
Created Feb 16, 2016 — forked from sddamico/LICENSE
Exponential Backoff Transformer
View RxponetialBackoff
/**
* @param interval The base interval to start backing off from. The function is: attemptNum^2 * intervalTime
* @param units The units for interval
* @param retryAttempts The max number of attempts to retry this task or -1 to try MAX_INT times,
*/
public static <T> Observable.Transformer<T, T> backoff(final long interval, final TimeUnit units, final int retryAttempts) {
return new Observable.Transformer<T, T>() {
@Override
public Observable<T> call(final Observable<T> observable) {
return observable.retryWhen(