Skip to content

Instantly share code, notes, and snippets.

View drewhannay's full-sized avatar

Drew Hannay drewhannay

View GitHub Profile
@drewhannay
drewhannay / FinishingActivityTestRule.java
Last active June 21, 2017 18:25
Android Espresso Activity Clean Up
/**
* Copyright (C) 2017 Drew Hannay
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
package com.linkedin.util;
import android.os.Bundle;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnitRunner;
import com.linkedin.android.testbutler.TestButler;
public class ExampleTestRunner extends AndroidJUnitRunner {
@Override
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
public class ${NAME} {
private static final String TAG = "${NAME}";
}
@drewhannay
drewhannay / ExpandableItemViewHolder.java
Created December 15, 2014 17:50
ExpandableItemViewHolder
import android.animation.ValueAnimator;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.animation.LinearInterpolator;
public abstract class ExpandableItemViewHolder extends RecyclerView.ViewHolder {
private int mOriginalHeight;
private boolean mIsViewExpanded;
@drewhannay
drewhannay / AsyncTaskLoaderBase.java
Last active August 29, 2015 14:05
Extension of Android's AsyncTaskLoader which takes care of the boilerplate details and adds support for loading Broadcasts
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.AsyncTaskLoader;
import android.support.v4.content.LocalBroadcastManager;
/**
* Base class which takes care of the boilerplate details involved in extending
* AsyncTaskLoader and adds convenience methods for registering and unregistering
* an observer for the Loader
*
@drewhannay
drewhannay / adbDb.sh
Created August 24, 2014 04:09
Simple shell script to pull, push, and list database files for an Android emulator or device
if [ $# -lt 1 ]
then
echo "Usage:"
echo " commands"
echo " setOptions \$databaseName \$packageName"
echo " ls"
echo " pull"
echo " push"
exit
@drewhannay
drewhannay / vim_commands
Last active December 13, 2015 23:39
Helpful Vim Commands
# Select entire paragraph and rewrap the text
vip gq
# vim LaTeX
zr # unfold one level
zR # unfold all levels
zm # fold one level
zM # fold all levels
\ll # compile LaTeX document
\lv # view compiled LaTeX PDF