Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍🚀
Jobandtalent and Storybeat

Marcos Trujillo Aracem

👨‍🚀
Jobandtalent and Storybeat
View GitHub Profile
@Aracem
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 https://github.com/sargunv/gson-kotlin
*/
internal class GsonKotlinAdapterFactory : TypeAdapterFactory {
private val Class<*>.isKotlinClass: Boolean
get() = declaredAnnotations.find { it.annotationClass.java.name == "kotlin.Metadata" } != null
@Aracem
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
package com.aracem.android
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
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
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 "com.aracem.android.ClasNameTest"
// 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
Aracem / TextColorMatcher
Created Mar 28, 2017
TextColorMatcher for your Espresso test
View TextColorMatcher
package com.homerthebulldog.android.matcher;
import android.content.res.Resources;
import android.support.annotation.ColorRes;
import android.support.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
@Aracem
Aracem / MasterTrackingHelper.java
Created Jul 21, 2015
Aspect Oriented Development with a Tracking Sample
View MasterTrackingHelper.java
package com.aracem.sample.tracking;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
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 project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
@Aracem
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 Upclose.me All rights reserved.
~
~ 0000000 xx
~ 00000000 xxxx
~ 0000000000 xxl
~ 00000000000000
~ 000000000000
~ 00000000
@Aracem
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;
View RippleDelayedRunner.java
package com.fewlaps.android.quitnow.base.customview;
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}
*
You can’t perform that action at this time.