Skip to content

Instantly share code, notes, and snippets.


Dominic Thomas dominicthomas

View GitHub Profile
dominicthomas / ripple_gradient_layer-list.xml
Created Aug 22, 2019
A ripple with a gradient overlay
View ripple_gradient_layer-list.xml
<ripple xmlns:android=""
<shape android:shape="rectangle">
dominicthomas /
Created May 13, 2019 — forked from patrickhammond/
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

ruby -e "$(curl -fsSL"
dominicthomas /
Created Nov 26, 2018
Custom lint class for check for and enforce custom xml headers
public class MissingXmlHeaderDetector extends ResourceXmlDetector {
public static final Issue ISSUE_MISSING_XML_HEADER = Issue.create(
"Flags xml files that don't have a header.",
"An xml file should always have the xml header to declare that it is an xml file despite the file ending.",
Category.CORRECTNESS, 10, Severity.ERROR,
new Implementation(MissingXmlHeaderDetector.class, Scope.RESOURCE_FILE_SCOPE));
dominicthomas /
Created Jul 4, 2018
Script that could be used to prepare and run ui tests
# Start an emulator
${ANDROID_HOME}/tools/emulator -avd ${EMULATOR_NAME} -wipe-data &
# Wait for Android to finish booting
dominicthomas / MatchChildViewWithText.kt
Created Jun 6, 2018
Use this to iterate through a recycler view item and check each position to see if a view exists that has some specific text set
View MatchChildViewWithText.kt
fun matchChildViewOfAccountTile(accountName: String, targetViewId: Int, itemMatcher: Matcher<View>): Matcher<View> =
object : BoundedMatcher<View, RecyclerView>( {
override fun describeTo(description: Description) {
description.appendText("Has view id $targetViewId and matches $itemMatcher for item with name $accountName")
public override fun matchesSafely(recyclerView: RecyclerView): Boolean {
val itemCount = recyclerView.adapter.itemCount
for (i in 0 until itemCount) {
val holder = recyclerView.findViewHolderForAdapterPosition(i)
dominicthomas /
Created Apr 4, 2018
Small snippet to check which thread an rxjava observable is requesting/returning on
public void testRxjavaThreading() throws InterruptedException {
final BlockingQueue<Runnable> tasks = new LinkedBlockingQueue<>();
System.out.println("Caller thread: " + Thread.currentThread().getName());
final Disposable subscribe = Observable.fromCallable(
new Callable<Integer>() {
public Integer call() throws Exception {
System.out.println("Observable thread: " + Thread.currentThread().getName());
dominicthomas / picasso_marker_image_target.txt
Last active Mar 26, 2017
Android Picasso target to display an image view in a map icon
View picasso_marker_image_target.txt
// Create new image target
final SimpleImageTarget newTarget = new SimpleImageTarget(
clusterItem.getSpot(), marker, markerImageView, iconGenerator);
// Store target reference - remove later
if (!imageTargets.containsKey(clusterItem.getSpot().getId())) {
imageTargets.put(clusterItem.getSpot().getId(), newTarget);
// Kick off image loading
dominicthomas / setup_bottom_navigation_view.txt
Created Jan 23, 2017
Quick guide on setting up a BottomNavigationView programatically..
View setup_bottom_navigation_view.txt
final BottomNavigationView bottomNavigationView = findViewById(;
bottomNavigationView.setItemTextColor(ContextCompat.getColorStateList(bottomNavigationView.getContext(), R.color.bottom_navigation_color_selector));
bottomNavigationView.setItemIconTintList(ContextCompat.getColorStateList(bottomNavigationView.getContext(), R.color.bottom_navigation_color_selector));
dominicthomas / max_height_linear_layout.txt
Created Dec 8, 2016
Enables you to set a max height for a linear layout while also using wrap content.. this means the layout will be collapsable but also have height constraints!
View max_height_linear_layout.txt
public class MaxHeightLinearLayout extends LinearLayout {
private int maxHeightDp;
public MaxHeightLinearLayout(Context context) {
public MaxHeightLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
dominicthomas / gradle_fabric_upload.txt
Created Nov 25, 2016
Code to upload a build to crashlytics even when setting a custom apk name.
View gradle_fabric_upload.txt
android {
debug {
debuggable true
ext.betaDistributionGroupAliases = "Android-Test"
... { variant ->
variant.preBuild.doLast {