Skip to content

Instantly share code, notes, and snippets.

@tir38
tir38 / build.gradle
Last active February 10, 2017 21:56
When running connectedCustomerDebugAndroidTest
apply plugin: 'com.android.application'
def supportLibVer = "25.0.1"
def googleServicesLibVer = "9.8.0"
def daggerLibVersion = "2.2"
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
@tir38
tir38 / example.java
Last active September 14, 2017 16:17
How do you prefer to use Dagger2?
// Given this module:
@Module
class DripCoffeeModule {
@Provides static Heater provideHeater() {
return new ElectricHeater();
}
}
// Which of these options do you prefer?
@tir38
tir38 / temp.java
Last active August 11, 2017 22:16
Questions about events and observables
package com.onbeep.obiwan.frameworks;
import io.reactivex.Observable;
public class Temp {
/**
* Question 1: should an event be a class or enum?
* <p>
* I don't have a good answer. Discussion going on here:
@tir38
tir38 / random_file.sh
Created December 29, 2017 16:49
Find a random file within an Android project (excluding generated files)
echo "Finding random file..."
# get all files in root dir
files=$(find . -type f)
# iterate over file list and filter out some things
saved_index=0
all_file_count=0
while read -r line; do
all_file_count=$(($all_file_count+1));
@tir38
tir38 / IdleUntilVisibleIdlingResource.java
Last active May 18, 2018 16:03
Ugly attempt to Idle Espresso test until view is visible. DO NOT USE THIS. Code sample for discussion here: https://issuetracker.google.com/issues/79626762
package com.example.app.tests;
import android.support.test.espresso.IdlingResource;
import android.support.test.espresso.ViewFinder;
import android.support.test.espresso.ViewInteraction;
import android.util.Log;
import android.view.View;
import java.lang.reflect.Field;
@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
@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 / 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 / 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 {
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 {