Skip to content

Instantly share code, notes, and snippets.

final OnVisibilityChangedListener searchVisibilityChangedListener = new OnVisibilityChangedListener() {
@Override
public void onShown(final FloatingActionButton fab) {
super.onShown(fab);
}
@Override
public void onHidden(final FloatingActionButton fab) {
super.onHidden(fab);
floatingActionButton.setImageResource(R.drawable.ic_search_white_24dp);
@jaredsburrows
jaredsburrows / gist:26bd0fe9f4c1dc7b3c37
Last active March 19, 2016 20:41
Java Integration Tests
// https://github.com/gradle/gradle/blob/master/subprojects/docs/src/samples/java/withIntegrationTests/build.gradle
// http://stackoverflow.com/questions/33751260/setting-up-integration-tests-in-android-gradle-based-project
// https://github.com/gradle/gradle/blob/21608d9b173fa53056563180575ec8c92df55dc7/gradle/integTest.gradle
apply plugin: 'java'
repositories {
mavenCentral()
}
adb shell am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///mnt/sdcard/Music
@jaredsburrows
jaredsburrows / gist:4548c65b21f860e8b4fd
Last active March 20, 2016 00:15
Publishing AARs locally
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' } // mirrors jcenter() and mavenCentral()
}
dependencies {
// Android gradle plugin
classpath 'com.android.tools.build:gradle:1.5.0'
// Google error-prone
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.8'
sourceSets {
integrationTest {
java.srcDir file('src/integration-test/java')
resources.srcDir file('src/integration-test/resources')
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
}
_ _ _ ____ _ _
| | | | __ _ ___| | __ | __ ) __ _ ___| | _| |
| |_| |/ _` |/ __| |/ / | _ \ / _` |/ __| |/ / |
| _ | (_| | (__| < | |_) | (_| | (__| <|_|
|_| |_|\__,_|\___|_|\_\ |____/ \__,_|\___|_|\_(_)
A DIY Guide
@jaredsburrows
jaredsburrows / PlayServicesUtils.java
Last active May 19, 2016 00:43
PlayServicesUtils for checking GPS
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
/**
* Google Play Services utility class.
@jaredsburrows
jaredsburrows / AnalyticsExceptionParser.java
Created May 19, 2016 01:23
Google Analytics and Crash Reporting
import android.util.Log;
import com.google.android.gms.analytics.ExceptionParser;
/**
* Custom Analytics Class to display enough debug information in the console.
*
* @author <a href="mailto:jaredsburrows@gmail.com">Jared Burrows</a>
*/
public final class AnalyticsExceptionParser implements ExceptionParser {
@jaredsburrows
jaredsburrows / proguard-logs.txt
Created September 1, 2016 06:04
Use proguard to remove logging on release
# Optimization needs to be turned on to remove logs
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
public static int wtf(...);
}
@jaredsburrows
jaredsburrows / RxBus1.java
Last active March 16, 2023 10:44
RxBus for RxJava 1 and RxJava 2
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
/**
* @author <a href="mailto:jaredsburrows@gmail.com">Jared Burrows</a>
*/
public final class RxBus {
private final Subject<Object, Object> bus = new SerializedSubject<>(PublishSubject.create());