Skip to content

Instantly share code, notes, and snippets.

@kingargyle
kingargyle / DBTestCase
Created February 24, 2014 20:07
Update of the DBUnit Test Case to work with JUnit 4 instead of relying on JUnit 3.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.dbunit.IDatabaseTester;
import org.dbunit.PropertiesBasedJdbcDatabaseTester;
import org.dbunit.database.IDatabaseConnection;
import org.junit.Assert;
/**
* Base testCase for database testing.<br>
* Subclasses may override {@link #newDatabaseTester()} to plug-in a different
@kingargyle
kingargyle / pom.xml
Created March 23, 2014 15:58
Mirror Eclipse ADT Plugins to a real P2 repository.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copy the old update site for ADT plugins into a p2 repository that can be used as part of a tycho build or to handle
cases where Eclipse complains about the external site not being available. This will create a new P2 repository instead
of the old site.xml based repository which is deprecated.
The p2 repository will be in the target/site/p2 directory when finished. You can then use as a local p2 repository in
Eclipse or deploy it to a web server and use it company wide.
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Shader.TileMode;
import android.util.AttributeSet;
@kingargyle
kingargyle / ShadowCookieManager
Created June 11, 2014 14:25
Extension of Robolectric ShadowCookieManager that implements setAcceptFileSchemeCookies and allowFileSchemeCookies
@Implements(value = CookieManager.class, inheritImplementationMethods = true)
public class ShadowCookieManager extends org.robolectric.shadows.ShadowCookieManager {
private static boolean acceptsFileSchemeCookies = false;
@Implementation
public static void setAcceptFileSchemeCookies(boolean fileSchemeCookies) {
acceptsFileSchemeCookies = fileSchemeCookies;
}
@kingargyle
kingargyle / disableGoogleAnalytics
Created June 24, 2014 18:02
Disable Google Analytics with Robolectric
// Place this in the setup method for any test that is failing to keep it from trying to start
ShadowApplication shadowApplication = Robolectric.shadowOf(Robolectric.application);
shadowApplication.declareActionUnbindable("com.google.android.gms.analytics.service.START");
@kingargyle
kingargyle / AndroidManifest.xml
Created August 5, 2014 13:19
Android TV Recommendation Handlers.
<!-- Required for on Android TV to receive Boot Completed events -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- Need to Register the Recommendation Intent Service -->
<service android:name="us.nineworlds.serenity.core.services.OnDeckRecommendationIntentService"
android:enabled="true" android:exported="true"/>
<!-- The Receiver that actually responds to the Boot Completed event, needed
to start the recommendation service automatically when bootup has
@kingargyle
kingargyle / WebViewDialogSoftKeyboard
Last active August 29, 2015 14:04
Resize Dialog for Soft Keyboard input with Text Views
/**
* Make sure that the Dialog size adjusts when the softlkeyboard is displayed.
*/
alertDialog.getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
/**
* Over ride onCheckIsTextEditor to always make sure the Webview
* brings up the softkeyboard when in an input field. There
* are situations like in a Dialog where the Softkeyboard will
@kingargyle
kingargyle / Gallery.java
Created August 19, 2014 14:29
Fix ItemLongClick and ItemClick both firing in Gallery widget
@kingargyle
kingargyle / TransitionDrawableRunnable.java
Created August 21, 2014 13:25
A runable that handles only transitioning and crossfading when the bitmaps are different.
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.preference.PreferenceManager;
import android.view.View;
/**
* A runnable that transitions between a drawable and a bitmap.
@kingargyle
kingargyle / update-manifest.xml
Last active August 29, 2015 14:06
Update Version Number in AndroidManifest with POM version number.
<!--
Include the following snippet in a profile or as part of your standard build.
It will parse out the POM version number and then use it to update the
version number in your AndroidManfiest.xml. It will also increment the
versionCode based on the version number.
No more manually having to update the vesion number as part of a release!! Yipee!
-->
<plugin>