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 . ja v a2 s. c o m*/ /** * Created by Alfredo "Rainbowbreeze" Morresi on 02/07/14. */ import java.util.ArrayList; import java.util.List; import it.rainbowbreeze.keepmoving.common.Utils; /** * Steps and information for a particular route */ public class Route { private final List<GeoPoint> mSteps; private int mLeavingTimestamp; public int getLeavingTimestamp() { return mLeavingTimestamp; } private int mArrivalTimestamp; public int getArrivalTimestamp() { return mArrivalTimestamp; } private int mTotalDuration; public int getTotalDuration() { return mTotalDuration; } public Route() { mSteps = new ArrayList<GeoPoint>(); } public List<GeoPoint> getSteps() { return mSteps; } public boolean isInvalid() { return mSteps.isEmpty(); } /** * Sets different parameters of the route based on its steps */ public void refreshTimestamps() { if (mSteps.isEmpty()) { mLeavingTimestamp = Utils.INVALID_TIMESTAMP; mArrivalTimestamp = Utils.INVALID_TIMESTAMP; return; } int totalTime = 0; for (GeoPoint step : mSteps) { if (step.isValidForAllTime()) { totalTime += step.getLenght(); continue; } mLeavingTimestamp = step.getValidTime() - totalTime; break; } totalTime = 0; for (int i=mSteps.size(); i>0; i--) { GeoPoint step = mSteps.get(i-1); totalTime += step.getLenght(); if (step.isValidForAllTime()) { continue; } mArrivalTimestamp = step.getValidTime() + totalTime; break; } mTotalDuration = mArrivalTimestamp - mLeavingTimestamp; } }