Skip to content

Instantly share code, notes, and snippets.

@kingargyle
kingargyle / MvpFrameLayout.java
Created August 17, 2017 12:54
Moxy MVP FrameLayout View example
package us.nineworlds.serenity.ui.views.mvp;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.os.Parcelable;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;
@kingargyle
kingargyle / C-kernel-codestyle-eclipse.xml
Created August 11, 2017 15:37 — forked from txomon/C-kernel-codestyle-eclipse.xml
This is a configuration file for eclipse to make C code follow as much as possible Linux Codystyle
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="1">
<profile kind="CodeFormatterProfile" name="Linux Kernel" version="1">
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.lineSplit" value="80"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_member_access" value="0"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
@kingargyle
kingargyle / libva.
Created July 31, 2017 01:49
LIBVa log files.
[35826.689183][ctx none]==========va_TraceInitialize
[35826.689201][ctx none]==========va_TraceCreateConfig
[35826.689203][ctx none] profile = 13
[35826.689204][ctx none] entrypoint = 6
[35826.689205][ctx none] num_attribs = 3
[35826.689206][ctx none] attrib_list[0].type = 0x00000000
[35826.689207][ctx none] attrib_list[0].value = 0x00000005
[35826.689208][ctx none] attrib_list[1].type = 0x00000005
[35826.689209][ctx none] attrib_list[1].value = 0x0000003e
[35826.689210][ctx none] attrib_list[2].type = 0x0000000a
@kingargyle
kingargyle / ShadowArrayAdapter.java
Created July 23, 2017 14:24
Robolectric ShadowArrayAdapter that allows access to the Drop Down Resource.
/**
* Shadow for {@link android.widget.ArrayAdapter}.
*/
@SuppressWarnings("UnusedDeclaration")
@Implements(ArrayAdapter.class)
public class ShadowArrayAdapter<T> extends ShadowBaseAdapter {
@RealObject
private ArrayAdapter<T> realArrayAdapter;
public int getTextViewResourceId() {
@kingargyle
kingargyle / AbstractNLSSupportTest.java
Created July 10, 2017 20:29
An proof of concept for adding NLS annotations to a test for testing nationalization of property files.
public abstract class AbstractNLSSupportTest {
@Rule
public TestName name = new TestName();
protected String propertiesFilename;
protected String brandId;
protected String language;
protected String country;
@kingargyle
kingargyle / Jackson1ConverterFactory
Created March 8, 2017 21:30 — forked from svendroid/Jackson1ConverterFactory
Retrofit Jackson1ConverterFactory
package retrofit;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.ResponseBody;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.ObjectReader;
import org.codehaus.jackson.map.ObjectWriter;
import org.codehaus.jackson.type.JavaType;
@kingargyle
kingargyle / RetrofitCachingExample.java
Created March 7, 2017 18:30 — forked from swankjesse/RetrofitCachingExample.java
Demonstrate HTTP caching with OkHttp and Retrofit.
/*
* Copyright (C) 2013 Square, Inc.
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@kingargyle
kingargyle / SelfReturningAnswer.java
Created February 1, 2017 15:15
Self Returning Answer for Mockito
public class SelfReturningAnswer implements Answer<Object> {
public Object answer(InvocationOnMock invocation) throws Throwable {
Object mock = invocation.getMock();
if( invocation.getMethod().getReturnType().isInstance( mock )){
return mock;
}
else{
return RETURNS_DEFAULTS.get().answer(invocation);
}
@kingargyle
kingargyle / ripple_selector.xml
Created October 17, 2016 16:45
Ripple Effect inside a selector
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/loyalty_button_reward_ripple">
<item android:id="@android:id/mask" android:drawable="@drawable/button_shopping_bag_loyalty_normal"/>
<item>
<selector>
<item android:state_enabled="true" android:drawable="@drawable/button_shopping_bag_loyalty_normal"/>
<item android:state_enabled="false" android:drawable="@drawable/button_shopping_bag_loyalty_rewards"/>
</selector>
</item>
@kingargyle
kingargyle / getActivityFromContextWrapper.java
Created September 21, 2016 13:48
Retrieve an Activity from a ContextWrapper
private Activity getActivity() {
Context context = getContext();
while (context instanceof ContextWrapper) {
if (context instanceof Activity) {
return (Activity)context;
}
context = ((ContextWrapper)context).getBaseContext();
}
return null;
}