Skip to content

Instantly share code, notes, and snippets.

View davidtcdeveloper's full-sized avatar

David Tiago Conceição davidtcdeveloper

  • Microsoft
  • Florianópolis, SC
View GitHub Profile
@davidtcdeveloper
davidtcdeveloper / Dockerfile
Created November 4, 2018 18:00
Creates an image for building Android Apps. Also enables instrumented tests ant emulator
# Dockerfile for Android app build. Can be used for native Android builds.
#
# Before building, you need to replace the values of variables
# ANDROID_SDK_LICENSE and ANDROID_SDK_PREVIEW_LICENSE (lines 70 and 71).
# Replace these values with contents of files android-sdk-license
# and android-sdk-preview-license that can be found at ANDROID_SDK/licenses.
# The line breakes are mandatory, use \n to add them.
FROM ubuntu:18.04
@davidtcdeveloper
davidtcdeveloper / Dockerfile
Created October 23, 2018 01:25
File for creating an image for Android applications build.
# Dockerfile for Android app build. Can be used for native Android builds.
#
# Before building, you need to replace the values of variables
# ANDROID_SDK_LICENSE and ANDROID_SDK_PREVIEW_LICENSE (lines 70 and 71).
# Replace these values with contents of files android-sdk-license
# and android-sdk-preview-license that can be found at ANDROID_SDK/licenses.
# The line breakes are mandatory, use \n to add them.
FROM ubuntu:16.04
//gradle.properties
dexMemory=3g
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m
org.gradle.configureondemand=true
org.gradle.caching=true
android.enableBuildCache=true
org.gradle.parallel=true
android.enableAapt2=true
android.enableD8=true
android.enableD8.desugaring = true
@davidtcdeveloper
davidtcdeveloper / DisableableAppBarLayoutBehavior.java
Last active March 7, 2017 14:04
Disables nested scroll and, by consequence, the expand/collapse from AppBar. Don't forget to manually expand/collapse app bar in code.
import android.content.Context;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.util.AttributeSet;
import android.view.View;
public class NestedScrollAppBarBehavior extends AppBarLayout.Behavior {
private boolean nestedScrollEnabled;
public DisableableAppBarLayoutBehavior() {
Gson gson = new GsonBuilder()
.registerTypeAdapterFactory(AutoValueGsonAdapterFactory.create())
.create();
@GsonTypeAdapterFactory
abstract class AutoValueGsonAdapterFactory implements TypeAdapterFactory {
static TypeAdapterFactory create() {
return new AutoValueGson_AutoValueGsonAdapterFactory();
}
}
@davidtcdeveloper
davidtcdeveloper / Test.java
Created May 29, 2016 18:12
Creating class with AutoValue builder
PersonData personData = PersonData.builder()
.id(1)
.name("David Tiago Conceição")
.eMail("david@david.com")
.status(0)
.profileUrl("twitter.com/davidtiagocon")
.pictureImageUrl("https://pbs.twimg.com/profile_images/601894402198544384/FJupV0uC.jpg")
.build();
//...
import com.ryanharter.auto.value.gson.AutoValueGsonTypeAdapterFactory;
//...
Gson gson = new GsonBuilder()
.registerTypeAdapterFactory(new AutoValueGsonTypeAdapterFactory())
.create();
@davidtcdeveloper
davidtcdeveloper / AutoValueTypeAdapterFactory.java
Last active May 29, 2016 18:27
Creating adapter factory to work with GSON.
public class AutoValueTypeAdapterFactory implements TypeAdapterFactory {
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
Class<? super T> rawType = type.getRawType();
if (PersonData.class.isAssignableFrom(rawType)) {
return (TypeAdapter<T>) PersonData.typeAdapter(gson);
}
return null;
}
}
@davidtcdeveloper
davidtcdeveloper / PersonData.java
Last active June 5, 2016 17:54
Adding GSON setup in our class.
public static TypeAdapter<PersonData> typeAdapter(Gson gson) {
return new AutoValue_PersonData.GsonTypeAdapter(gson);
}