Skip to content

Instantly share code, notes, and snippets.

View adavis's full-sized avatar

Annyce Davis adavis

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape android:shape="rectangle">
<solid android:color="@color/light_blue"/>
</shape>
</item>
@adavis
adavis / android_wearable_connected
Created July 28, 2014 14:46
How to determine if an Android Wear device is connected
private boolean isConnectedToWearable = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!servicesAvailable()) {
finish();
}
@adavis
adavis / android_box_inset_layout
Created September 11, 2014 17:32
An example of using the Wearable Support BoxInsetLayout view
<android.support.wearable.view.BoxInsetLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent">
<LinearLayout
android:id="@+id/textViewsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
@adavis
adavis / custom_gson_deserialization
Created October 28, 2014 18:30
Custom Gson Deserialization
public class CarVO implements Serializable {
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface SkipThis {
// Field tag only annotation
}
private static final long serialVersionUID = 1824858721250363381L;
@adavis
adavis / blur_darken_transform
Last active December 23, 2020 22:51
This is a Picasso transform that blurs and darkens an image.
private final class BlurTransform implements Transformation {
WeakReference<Context> context;
public BlurTransform(Context context) {
super();
this.context = new WeakReference<>(context);
}
@Override
@adavis
adavis / async_task_live_template
Created June 8, 2015 19:44
A simple live template for Android Studio that surrounds the current selection with an Async Task.
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
$SELECTION$
return null;
}
@Override
protected void onPostExecute(Void result) {
@adavis
adavis / checkstyle
Created June 22, 2015 20:06
Checkstyle configuration for use in Android projects.
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
<module name="FileLength"><property name="max" value="800"/></module>
<module name="TreeWalker">
<module name="MethodLength"><property name="max" value="60"/></module>
@adavis
adavis / cobertura_spring_boot
Created July 12, 2015 18:44
Cobertura Coverage for Spring Boot App
plugins {
id 'net.saliman.cobertura' version '2.2.7'
}
cobertura {
coverageFormats = ['html', 'xml']
coverageIgnoreTrivial = true
coverageIgnores = []
coverageReportDir = new File("$buildDir/reports/cobertura")
}
<FindBugsFilter>
<Match>
<Class name="~.*R\$.*"/>
</Match>
<Match>
<Class name="~.*Manifest\$.*"/>
</Match>
<Match>
<Class name="~.*_234$"/>
</Match>
@adavis
adavis / WrongVideo.java
Last active January 9, 2016 17:26
Demonstrates needless data being created inside test method
package info.adavis.sample.models;
/**
* Sample Domain Object used for demonstration
*
* @author Annyce Davis
*/
public class Video {
private long id;