Skip to content

Instantly share code, notes, and snippets.

Eugenio Marletti Takhion

Block or report user

Report or block Takhion

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View MapWrapper.java
import android.content.Intent;
import android.support.annotation.NonNull;
import java.io.Serializable;
import java.util.Map;
/**
* Provides a way to wrap a serializable {@link Map} in order to preserve its class
* during serialization inside an {@link Intent}, otherwise it would be "flattened"
* in a {@link android.os.Parcel} and unparceled as a {@link java.util.HashMap}.
View MapSerializer.java
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
View AnimatorUtils.java
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.Keyframe;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.os.Build;
import android.support.annotation.Nullable;
import java.lang.reflect.Field;
View HistoryTransformer.java
import android.support.v4.util.Pair;
import rx.Observable;
public class HistoryTransformer<T> implements Observable.Transformer<T, Pair<T,T>> {
@Override
public Observable<Pair<T,T>> call(Observable<T> observable) {
//noinspection unchecked
return observable
.map(value -> {
@Takhion
Takhion / WindowAware.java
Created Jun 3, 2015
RecyclerView that calls onAttachedToWindow/onDetachedFromWindow on its adapter
View WindowAware.java
public interface WindowAware {
public void onAttachedToWindow();
public void onDetachedFromWindow();
}
@Takhion
Takhion / styles.xml
Created Jun 3, 2015
Custom dialog Activity style
View styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="CustomDialog" parent="@style/Base.Theme.AppCompat.Light.Dialog.FixedSize">
<item name="android:windowCloseOnTouchOutside">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowClipToOutline">false</item>
@Takhion
Takhion / AndroidManifest.xml
Created Jun 1, 2015
Task killer for Android
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity android:name=".TaskKiller"/>
</application>
@Takhion
Takhion / SwitchFamilyName.java
Last active Jan 1, 2016
A android.widget.Switch that accepts the attribute "android:fontFamily" inside a style defined by the attribute "android:switchTextAppearance". Makes sense from API 16+ as before the attribute doesn't exist; however it can easily be modified with a custom one.
View SwitchFamilyName.java
package android.widget;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.Switch;
/**
@Takhion
Takhion / RetainedObservableActivity.java
Last active Sep 30, 2016
Simplest way to retain an active Observable during configuration changes
View RetainedObservableActivity.java
package me.eugeniomarletti.example;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.widget.Toast;
import rx.Observable;
import rx.Subscriber;
import rx.Subscription;
@Takhion
Takhion / build.gradle
Created May 30, 2015
Automatic Java home (7/8) for Retrolambda with Gradle
View build.gradle
String getJavaHome(String version)
{
def stdout = new ByteArrayOutputStream()
exec {
commandLine "/usr/libexec/java_home", "-v", version
standardOutput = stdout;
}
return stdout.toString().trim()
}
You can’t perform that action at this time.