Android Open Source - keepmoving Route






From Project

Back to project page keepmoving.

License

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.

Java Source Code

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;
    }
}




Java Source Code List

it.rainbowbreeze.keepmoving.ApplicationTest.java
it.rainbowbreeze.keepmoving.common.Config.java
it.rainbowbreeze.keepmoving.common.DaggerModule.java
it.rainbowbreeze.keepmoving.common.ILogManager.java
it.rainbowbreeze.keepmoving.common.LogManager.java
it.rainbowbreeze.keepmoving.common.MyApp.java
it.rainbowbreeze.keepmoving.common.Utils.java
it.rainbowbreeze.keepmoving.data.GeoPointDao.java
it.rainbowbreeze.keepmoving.data.GeoPointFixedRepository.java
it.rainbowbreeze.keepmoving.data.IGeoPointRepository.java
it.rainbowbreeze.keepmoving.domain.Coord.java
it.rainbowbreeze.keepmoving.domain.GeoPointTypes.java
it.rainbowbreeze.keepmoving.domain.GeoPoint.java
it.rainbowbreeze.keepmoving.domain.Route.java
it.rainbowbreeze.keepmoving.domain.Weekdays.java
it.rainbowbreeze.keepmoving.logic.PositionManager.java
it.rainbowbreeze.keepmoving.logic.RouteManager.java
it.rainbowbreeze.keepmoving.logic.TimetableController.java
it.rainbowbreeze.keepmoving.logic.TimetableModel.java
it.rainbowbreeze.keepmoving.ui.SpannableHelper.java
it.rainbowbreeze.keepmoving.ui.StepsArrayAdapter.java
it.rainbowbreeze.keepmoving.ui.TimetableActivity.java
it.rainbowbreeze.keepmoving.ui.TimetableActivity.java
it.rainbowbreeze.keepmoving.ui.TimetableFragment.java