Back to project page keepmoving.
The source code is released under:
GNU General Public License
If you think the Android project keepmoving listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package it.rainbowbreeze.keepmoving.domain; // w w w. j a va 2 s . c om import android.text.TextUtils; import java.util.HashMap; import it.rainbowbreeze.keepmoving.common.Utils; /** * This file is part of KeepMoving. KeepMoving 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, version 2. * <p/> * 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. * <p/> * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * <p/> * Copyright Alfredo Morresi * <p/> * Created by Alfredo "Rainbowbreeze" Morresi on 14/06/14. */ public class GeoPoint { private static final int ALWAYS_AVAILABLE_FOR_TIME = -1; /** * The type of the point */ private GeoPointTypes mType; public GeoPointTypes getType() { return mType; } public GeoPoint setType(GeoPointTypes newValue) { this.mType = newValue; return this; } /** * Time required to go through this point (in minutes) */ private int mLenght; public int getLenght() { return mLenght; } public GeoPoint setLenght(int lenght) { this.mLenght = lenght; return this; } /** * Starting coordinate of the point */ private Coord mStartCoord; public Coord getStartCoord() { return mStartCoord; } public GeoPoint setStartCoord(Coord newValue) { this.mStartCoord = newValue; return this; } /** * Ending coordinate of the point */ private Coord mEndCoord; public Coord getEndCoord() { return mEndCoord; } public GeoPoint setEndCoord(Coord newValue) { this.mEndCoord = newValue; return this; } /** * Name of the point */ private String mName; public String getName() { return mName; } public GeoPoint setName(String newValue) { this.mName = newValue; return this; } /** * Day of the week when the point is valid. Null equals to always */ private final HashMap<Weekdays, Boolean> mValidDays = new HashMap<Weekdays, Boolean>(7); public GeoPoint setValidAllDays() { return setValidDays(true, true, true, true, true, true, true); } public GeoPoint setValidWeekDays() { return setValidDays(true, true, true, true, true, false, false); } public GeoPoint setValidWeekend() { return setValidDays(false, false, false, false, false, true, true); } public GeoPoint setValidSaturday() { return setValidDays(false, false, false, false, false, true, false); } public GeoPoint setValidSunday() { return setValidDays(false, false, false, false, false, false, true); } /** * Hour:minute of the day when the point is valid. 0 equals to always. Express in minutes * from 00:00, so 10 means 00:10, 75 means 01:15 and so on. * -1 means always valid (like for a type_walk) */ private int mValidTime; public int getValidTime() { return mValidTime; } public GeoPoint setValidTime(int newValue) { this.mValidTime = newValue; return this; } public GeoPoint setValidAllTime() { this.mValidTime = ALWAYS_AVAILABLE_FOR_TIME; return this; } public GeoPoint setValidTime(String time) { setValidTime(Utils.getTimestampFromTime(time)); return this; } private GeoPoint setValidDays(boolean mon, boolean tue, boolean wed, boolean thu, boolean fri, boolean sat, boolean sun) { mValidDays.put(Weekdays.Mon, mon); mValidDays.put(Weekdays.Tue, tue); mValidDays.put(Weekdays.Wed, wed); mValidDays.put(Weekdays.Thu, thu); mValidDays.put(Weekdays.Fri, fri); mValidDays.put(Weekdays.Sat, sat); mValidDays.put(Weekdays.Sun, sun); return this; } public boolean isValidForAllTime() { return ALWAYS_AVAILABLE_FOR_TIME == mValidTime; } @Override public String toString() { return TextUtils.isEmpty(getName()) ? String.format("P %s - %s", getStartCoord(), getEndCoord()) : getName(); } @Override public boolean equals(Object o) { if (null == o) return false; if (!(o instanceof GeoPoint)) return false; GeoPoint other = (GeoPoint) o; boolean isEqual = true; isEqual &= null == mEndCoord ? null == other.mEndCoord : mEndCoord.equals(other.mEndCoord); isEqual &= mLenght == other.mLenght; isEqual &= null == mName ? null == other.mName : mName.equals(other.mName); isEqual &= null == mStartCoord ? null == other.mStartCoord : mStartCoord.equals(other.mStartCoord); isEqual &= mType == other.mType; isEqual &= mValidTime == other.mValidTime; //TODO put also ValidDays return isEqual; } }