/*******************************************************************************
* Copyright (c) 2011 Michel DAVID mimah35-at-gmail.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package fr.gotorennes.domain;
import java.util.Date;
import android.os.Parcel;
import android.os.Parcelable;
public class NextDeparture implements Parcelable {
public String stopId;
public String routeId;
public int direction;
public Date remoteDate;
public Date departure;
public NextDeparture() {
super();
}
public int getMinutesBeforeDeparture() {
return (int) (departure.getTime() - remoteDate.getTime()) / 60000;
}
@Override
public int describeContents() {
return 0;
}
public NextDeparture(Parcel in) {
stopId = in.readString();
routeId = in.readString();
direction = in.readInt();
remoteDate = new Date(in.readLong());
departure = new Date(in.readLong());
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeString(stopId);
out.writeString(routeId);
out.writeInt(direction);
out.writeLong(remoteDate.getTime());
out.writeLong(departure.getTime());
}
public static final Parcelable.Creator<NextDeparture> CREATOR = new Parcelable.Creator<NextDeparture>() {
@Override
public NextDeparture createFromParcel(Parcel in) {
return new NextDeparture(in);
}
@Override
public NextDeparture[] newArray(int size) {
return new NextDeparture[size];
}
};
}