Skip to content

Instantly share code, notes, and snippets.

@tir38
tir38 / runSubsetOfInstrumentationTests.sh
Last active February 5, 2020 23:35
Android: Run instrumentation tests on a single class or single method
#!/bin/bash
if [ -z "$1" ]; then
echo "Must specify module (e.g. app)"
exit 1
fi
if [ -z "$2" ]; then
echo "Must specify build type, starting w/ capital letter (e.g. Debug, DebugFree, ReleasePaid)"
exit 1
@tir38
tir38 / androidx_test_switching.sh
Created March 29, 2019 22:09
Switching back and forth between Android and AndroidX Test Orchestrator? You'll want to remove old test packages in between.
#!/bin/bash
# Uninstall androidx things
adb uninstall androidx.test.orchestrator
adb uninstall androidx.test.services
# uninstall old android things
adb uninstall android.support.test.services
adb uninstall android.support.test.orchestrator
@tir38
tir38 / gist:87b73913233d8f1fb448375d01c91746
Created February 20, 2019 21:02
403 when running flank/fladle via bitrise
> Task :app:assembleDebugAndroidTest
> Task :app:assembleAndroidTest
Download https://github.com/TestArmada/flank/releases/download/v4.2.0/flank.jar
> Task :app:downloadFlank
> Task :app:writeConfigProps
> Task :app:execFlank FAILED
Exception in thread "main" picocli.CommandLine$ExecutionException: Error while running command (ftl.cli.firebase.test.android.AndroidRunCommand@71454b9d): com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
@tir38
tir38 / Example.java
Last active December 14, 2018 19:26
Using delay does not work like I think it does
package com.example;
import org.junit.Test;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.observers.TestObserver;
import io.reactivex.schedulers.Schedulers;
package com.example;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.Observable;
import io.reactivex.exceptions.CompositeException;
import io.reactivex.exceptions.Exceptions;
package com.example;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
public class Temp {
@tir38
tir38 / Test.java
Last active July 24, 2018 19:15
Copy via builder does not defensive copy interceptors. https://github.com/square/okhttp/issues/4168
import android.util.Log;
import java.util.List;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
public class Test {
@tir38
tir38 / Test.java
Created July 12, 2018 21:09
RxJava2 example of how to start/stop an emitter on first subscribe/last unsubscribe
package com.example;
import android.annotation.SuppressLint;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import io.reactivex.Emitter;
import io.reactivex.Observable;
import io.reactivex.ObservableOnSubscribe;
@tir38
tir38 / _README.md
Last active June 29, 2018 17:18
BuildConfig.DEBUG is a per-gradle-module concept

BuildConfig.DEBUG is a per-Gradle-module concept

I have three build types: debug, dogfood, and release.

In app's build.gradle I define which build types are "debuggable".

I also have a library Gradle module as a dependency.

Inside library's build.gradle I define the same three build types.

@tir38
tir38 / _original_example.java
Last active June 20, 2018 23:23
How nasty is this RX?
@Override
public Single<User2> updatePhone(String phoneNumber) {
String userId = user.getId();
// even though server allows a user to have multiple phone numbers; product requirements are that user can have
// only 0 or 1 phone number. So start off by removing ALL existing phone numbers, and then adding new one.
// This is how iOS does it.
// things to note:
// * we can only remove phones one-by-one; there is no batch web request