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 / build.gradle
Last active February 26, 2017 19:02
GSON setup.
annotationProcessor 'com.ryanharter.auto.value:auto-value-gson:0.3.1'
compile 'com.google.code.gson:gson:2.6.2'
@davidtcdeveloper
davidtcdeveloper / AutoValue_PersonData.java
Created May 28, 2016 17:45
Parcelable generated implementation.
public static final Parcelable.Creator<AutoValue_PersonData> CREATOR = new Parcelable.Creator<AutoValue_PersonData>() {
@Override
public AutoValue_PersonData createFromParcel(Parcel in) {
return new AutoValue_PersonData(
in.readLong(),
in.readString(),
in.readInt(),
in.readString(),
in.readString(),
in.readInt() == 0 ? in.readString() : null
@davidtcdeveloper
davidtcdeveloper / PersonData.java
Created May 28, 2016 17:44
Implementing Parcelable
@AutoValue
public abstract class PersonData implements Parcelable {
@davidtcdeveloper
davidtcdeveloper / Module build.gradle
Last active February 26, 2017 19:02
Adding parcelable extension.
annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.2'
public boolean hasProfilePicure() {
return this.profileUrl() != null;
}
@davidtcdeveloper
davidtcdeveloper / 1. PersonData.java
Last active May 29, 2016 18:15
Setting up a nullable field.
@Nullable
abstract String pictureImageUrl();
@davidtcdeveloper
davidtcdeveloper / AutoValue_PersonData.java
Last active May 28, 2016 17:31
Null checks in generated class.
if (pictureImageUrl == null) {
throw new NullPointerException("Null pictureImageUrl");
}
@davidtcdeveloper
davidtcdeveloper / PersonData.java
Created May 26, 2016 19:19
Replacing create with builder.
static Builder builder() {
return new AutoValue_PersonData.Builder();
}
@davidtcdeveloper
davidtcdeveloper / PersonData.java
Created May 26, 2016 19:19
Creating a builder with AutoValue.
@AutoValue.Builder
abstract static class Builder {
abstract Builder id(long value);
abstract Builder name(String value);
abstract Builder status(int value);
abstract Builder eMail(String value);
abstract Builder profileUrl(String value);
abstract Builder pictureImageUrl(String value);
abstract PersonData build();
}
@davidtcdeveloper
davidtcdeveloper / PersonData.java
Last active May 28, 2016 17:30
Create method.
public static PersonData create(long id, String name, int status, String eMail,String profileUrl, String pictureImageUrl) {
return new AutoValue_PersonData(id, name, status, eMail, profileUrl, pictureImageUrl);
}