Skip to content

Instantly share code, notes, and snippets.

View briangriffey's full-sized avatar

brian griffey briangriffey

View GitHub Profile
@briangriffey
briangriffey / VolleyAction
Created October 16, 2015 21:06
ResponseListenerAction.java
public class ResponseListenerAction<T> implements Action1<T> {
private Response.Listener<T> responseListener;
public ResponseListenerAction(Response.Listener<T> responseListener) {
this.responseListener = responseListener;
}
@Override
@briangriffey
briangriffey / sync cocktail
Created August 4, 2014 03:16
sync cocktail
ContentResolver.setIsSyncable(account, StubProvider.AUTHORITY, 1);
ContentResolver.setSyncAutomatically(account, StubProvider.AUTHORITY, true);
ContentResolver.addPeriodicSync(account, StubProvider.AUTHORITY, new Bundle(), AbstractSyncableResource.SYNC_TIME);
package com.homeaway.floatlabel.library;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
@briangriffey
briangriffey / ShareProvider
Last active June 17, 2016 17:03
How to change an icon on the shareactionprovider
package com.wahtever.views.actionbar;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ShareActionProvider;
import com.whatever.R;
import java.lang.reflect.InvocationTargetException;
@briangriffey
briangriffey / important gradle pieces
Last active August 29, 2015 14:00
Gradle pieces needed for robolectric integration in Android Studio
task robolectric(type: Test, dependsOn: assembleRelease) {
testClassesDir = sourceSets.robolectric.output.classesDir
android.sourceSets.main.java.srcDirs.each { dir ->
project.getPlugins().getPlugin('android').prepareTaskMap.each {
sourceSets.robolectric.compileClasspath += files(it.value.explodedDir.getAbsolutePath() + '/classes.jar')
sourceSets.robolectric.runtimeClasspath += files(it.value.explodedDir.getAbsolutePath() + '/classes.jar')
}
@briangriffey
briangriffey / CuttingOffTextView.java
Created November 13, 2013 22:14
Makes sure text doesn't go beyond the boundaries of its measured height and adjusts itself to the maximum appropriate lines.
package com.vice.viceforandroid.views;
import android.content.Context;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.TextView;
/**
* Created by briangriffey on 11/13/13.
@briangriffey
briangriffey / CircularDrawable.java
Last active December 25, 2015 20:29
Use this drawable to to create a circular image like the one found here: https://www.evernote.com/shard/s36/sh/9f22cbd4-9e01-4f7a-9125-2470c4f21e6c/be052171b03a4ad8dc308560971c5944 with any bitmap.
package com.sceneTap.views;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Shader;
@briangriffey
briangriffey / gist:6528687
Last active December 22, 2015 20:49
Simple addition to any gradle file to install to your local repository
uploadArchives {
repositories {
mavenDeployer {
repository url: 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
pom.artifactId = "yourartifactname"
pom.groupId = "com.yourgroup"
pom.version = "1.0.0-SNAPSHOT"
}
@briangriffey
briangriffey / NinePatchBitmapFactory.java
Last active April 25, 2023 03:06
Create 9-patches simlar to - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.NinePatch;
import android.graphics.Rect;
import android.graphics.drawable.NinePatchDrawable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**