Skip to content

Instantly share code, notes, and snippets.

Jobandtalent and Storybeat

Marcos Trujillo Aracem

Jobandtalent and Storybeat
View GitHub Profile
Aracem / GsonKotlinAdapterFactory
Last active Nov 30, 2018
Gson adapter to add kotlin optionals check to gson deserializer
View GsonKotlinAdapterFactory
private val TAG: String = "GsonKotlinAdapter"
* GsonKotlinAdapterFactory inspired by
internal class GsonKotlinAdapterFactory : TypeAdapterFactory {
private val Class<*>.isKotlinClass: Boolean
get() = declaredAnnotations.find { == "kotlin.Metadata" } != null
Aracem / OptionalExtension.kt
Last active Oct 18, 2018
Elvis operator could not contains lambdas or several method calls, only 1 expresion. if var != null could not ensure unwrapping i.e. if var is a class property. These function extensions resolve these problems
View OptionalExtension.kt
inline fun <T, K> T?.ifPresent(block: (T) -> K): K? {
return this?.let { block.invoke(it) }
inline fun <K> K?.orElse(block: () -> K): K {
return this?.let { it } ?: block.invoke()
Aracem / OnPageChangeListenerAdapter
Created May 23, 2018
OnPageChangeListenerAdapter to easily implement this listener
View OnPageChangeListenerAdapter
open class OnPageChangeListenerAdapter : OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) {
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
override fun onPageSelected(position: Int) {
Aracem / LaunchTestFromTerminal.txt
Last active Jan 31, 2020
Launch an unit test using a terminal
View LaunchTestFromTerminal.txt
// Launch a test from a terminal
./gradlew :module:testFlavourBuildType --tests "*ClassNameTest"
./gradlew :module:testFlavourBuildType --tests ""
// To attach Android Studio debugger
./gradlew :module:testFlavourBuildType --tests "*ClassNameTest" --debug-jvm
// Then wait until the compilation finished and attach a debuger. In Android studio use CTRL + SHIFT + A,
// search for "Debugger" and select attach to local source
Aracem / TextColorMatcher
Created Mar 28, 2017
TextColorMatcher for your Espresso test
View TextColorMatcher
import android.content.res.Resources;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
Aracem /
Created Jul 21, 2015
Aspect Oriented Development with a Tracking Sample
package com.aracem.sample.tracking;
import android.content.Context;
import com.aracem.sample.tracking.trackingservice.MixpanelTrackingHelper;
import com.aracem.sample.tracking.trackingservice.GoogleAnalyticsTrackingHelper;
View Proguard config
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/panavtec/Documents/android-sdk-macosx/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in
# For more details, see
# Add any project specific keep options here:
Aracem / AndroidManifest.xml
Last active Mar 22, 2016
Speedup Compile time in debug enabling vmSafeMode. USe this Manifest in your debug folder
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
~ Copyright (c) 2015 All rights reserved.
~ 0000000 xx
~ 00000000 xxxx
~ 0000000000 xxl
~ 00000000000000
~ 000000000000
~ 00000000
Aracem / AnimationViewUtils
Created Mar 19, 2015
Tada Animation from Cyrill Mottier
View AnimationViewUtils
package com.aracem.utils.animation;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.Keyframe;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.view.View;
* A simple way to call the common new Handler().postDelayed(..., time);
* to show the Ripple animation completely and then run a Runnable. This class
* have to be used like a {@link android.view.View.OnClickListener}