All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.example.pocketknife.MyParcelable Maven / Gradle / Ivy

The newest version!
package com.example.pocketknife;

import android.os.Parcel;
import android.os.Parcelable;

public class MyParcelable implements Parcelable {
    private int data;

    public MyParcelable(int data) {
        this.data = data;
    }

    private MyParcelable(Parcel in) {
        data = in.readInt();
    }

    @Override
    public int hashCode() {
        return Integer.valueOf(data).hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        return obj instanceof MyParcelable && ((MyParcelable) obj).data == this.data;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeInt(data);
    }

    public static final Creator CREATOR = new Creator() {
        @Override
        public MyParcelable createFromParcel(Parcel in) {
            return new MyParcelable(in);
        }

        @Override
        public MyParcelable[] newArray(int size) {
            return new MyParcelable[size];
        }
    };

    public int getData() {
        return data;
    }

    public void setData(int data) {
        this.data = data;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy