Skip to content

Instantly share code, notes, and snippets.

@lucas-marciano
Created September 20, 2016 03:20
Show Gist options
  • Select an option

  • Save lucas-marciano/fde17f182271f4c1b001f3dfa3d706c9 to your computer and use it in GitHub Desktop.

Select an option

Save lucas-marciano/fde17f182271f4c1b001f3dfa3d706c9 to your computer and use it in GitHub Desktop.
import android.os.Parcel;
import android.os.Parcelable;
public class Cliente implements Parcelable {
private int codigo;
private String nome;
public Cliente(int codigo, String nome) {
this.codigo = codigo;
this.nome = nome;
}
private Cliente(Parcel p){
codigo = from.readInt();
nome = from.readString();
}
public static final Parcelable.Creator<Cliente>
CREATOR = new Parcelable.Creator<Cliente>() {
public Cliente createFromParcel(Parcel in) {
return new Cliente(in);
}
public Cliente[] newArray(int size) {
return new Cliente[size];
}
};
public int getCodigo() {
return codigo;
}
public void setCodigo(int codigo) {
this.codigo = codigo;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(codigo);
dest.writeString(nome);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment