Skip to content

Instantly share code, notes, and snippets.

View Aracem's full-sized avatar
👨‍🚀
Jobandtalent and Storybeat

Marcos Trujillo Aracem

👨‍🚀
Jobandtalent and Storybeat
View GitHub Profile
@Aracem
Aracem / ParallaxPageTransformer.java
Last active March 8, 2023 17:28
Parallax transformer for ViewPagers that let you set different parallax effects for each view in your Fragments.
package com.aracem.utils.animations.pagetransformation;
import org.jetbrains.annotations.NotNull;
import android.support.v4.view.ViewPager;
import android.view.View;
import java.util.ArrayList;
import java.util.List;
@Aracem
Aracem / BaseWebView.java
Created May 9, 2013 09:32
Base WebView perfect to extend in your project and initialize it like you want -- this implementation hasn't any inicialization -- It has a workaround to avoid problems on Android 4.2.x version with the webview implemented by Jose I Honrado Has a method to load a Error page. Has a method to enable with reflection (when possible) the "plugins" at…
package com.acdroid.widget.webview;
import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebView;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
@Aracem
Aracem / SupportVersion.java
Last active August 4, 2021 11:19
SupportVersion Utils class to check if the current API version is as least certain API Level
package com.aracem.utils.version;
import android.os.Build;
/**
* Util class to check if the current device is running some of the awesome Android versions.
* <p/>
* Created by Marcos Trujillo (─‿‿─) on 3/02/14.
*/
public class SupportVersion {
@Aracem
Aracem / LaunchTestFromTerminal.txt
Last active January 31, 2020 12:24
Launch an unit test using a terminal
// 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 / GsonKotlinAdapterFactory
Last active November 30, 2018 10:25
Gson adapter to add kotlin optionals check to gson deserializer
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 October 18, 2018 10:21
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
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 / OverrideTypefaceApplication.java
Last active May 31, 2018 23:19 — forked from artem-zinnatullin/MyApp.java
Example to override the default font of an Application.
public class OverrideTypefaceApplication extends Application {
@Override
public void onCreate() {
TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/Roboto-Regular.ttf"); // font from assets: "assets/fonts/Roboto-Regular.ttf
}
}
@Aracem
Aracem / OnPageChangeListenerAdapter
Created May 23, 2018 17:04
OnPageChangeListenerAdapter to easily implement this listener
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 / styles.xml
Last active July 11, 2017 15:48
Material Text Styles supported for all version with Appcompat + Calligraphy Library ( https://github.com/chrisjenx/Calligraphy ) Material Design recomendations http://www.google.com/design/spec/style/typography.html#typography-roboto-noto Remember to add the fonts to your source/fonts folder
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- TextView Empty Base-->
<style name="TextViewBase" parent="android:TextAppearance.Holo.Widget.TextView"/>
<!-- ActionBar Title -->
<style name="CustomActionBarTitleBase" parent="TextAppearance.AppCompat.Widget.ActionBar.Title"/>
<!-- Text Views Default Base -->
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#fde0dc</color>
<color name="md_red_100">#f9bdbb</color>
<color name="md_red_200">#f69988</color>