Android Open Source - activity-tracker Converter






From Project

Back to project page activity-tracker.

License

The source code is released under:

MIT License

If you think the Android project activity-tracker 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 org.hopto.mjancola.utility;
// w ww . ja v  a2  s .c  o m
import android.content.Context;
import com.google.android.gms.location.DetectedActivity;
import org.hopto.mjancola.model.LearningMode;

public class Converter
{
    private static final double METERS_TO_MILES             = 0.000621371;
    private static final double MPS_TO_MPH                  = 2.23694;

    public static String formatDuration( final long durationMS )
    {
        long totalSeconds = ( durationMS / 1000L );
        long seconds = totalSeconds % 60;

        long totalMinutes = totalSeconds / 60;
        long minutes = totalMinutes % 60;

        long totalHours = totalMinutes / 60;
        long hours = totalHours % 60;
        return String.format("%02d:%02d:%02d", hours, minutes, seconds);
    }

    public static long formatDistanceTimeOneHundred(final double distance)
    {
        return Math.round(distance * 100);
    }

    public static String formatDistance(final double distance)
    {
        // convert meters to miles
        return String.format("%2.2f", (distance * METERS_TO_MILES));
    }

    public static String formatSpeed(final double metersPerSecond)
    {
        // convert meters to miles
        return String.format("%2.2f", (metersPerSecond * MPS_TO_MPH));
    }

    public static String getMovementFromDetectedActivity( DetectedActivity motion, Context context )
    {
        if (motion.getConfidence() < SettingsHelper.getInstance( context ).getActivityChangePercent())
        {
            return null;
        }
        switch ( motion.getType() )
        {
            case 0:
                return LearningMode.CAR_NAME;
            case 1:
                return LearningMode.BIKE_NAME;
            case 2:
                return LearningMode.FOOT_NAME;
            case 3:
                return LearningMode.IDLE;
//          // IGNORING other cases (UNKNOWN, and TILT)
            default:
                return null;

        }
    }

}




Java Source Code List

org.hopto.mjancola.ActivityTrackerApplication.java
org.hopto.mjancola.activity.ActivityRecognitionActivity.java
org.hopto.mjancola.activity.ActivityTracker.java
org.hopto.mjancola.activity.DemoDetailsList.java
org.hopto.mjancola.activity.DemoDetails.java
org.hopto.mjancola.activity.EditWorkoutDAOActivity.java
org.hopto.mjancola.activity.FeatureView.java
org.hopto.mjancola.activity.LegalInfoActivity.java
org.hopto.mjancola.activity.ListWorkoutsActivity.java
org.hopto.mjancola.activity.MyLocationDemoActivity.java
org.hopto.mjancola.activity.SpeedActivity.java
org.hopto.mjancola.activity.UserSettingsActivity.java
org.hopto.mjancola.adapter.WorkoutDAOAdapter.java
org.hopto.mjancola.fragment.EditWorkoutDAOFragment.java
org.hopto.mjancola.model.DataPoint.java
org.hopto.mjancola.model.GenericMovement.java
org.hopto.mjancola.model.GenericWorkout.java
org.hopto.mjancola.model.LearningMode.java
org.hopto.mjancola.model.MyMovement.java
org.hopto.mjancola.model.WorkoutTotal.java
org.hopto.mjancola.model.WorkoutType.java
org.hopto.mjancola.model.Workout.java
org.hopto.mjancola.service.ActivityRecognitionService.java
org.hopto.mjancola.service.MovementListenerService.java
org.hopto.mjancola.service.MovementTrackerService.java
org.hopto.mjancola.utility.Converter.java
org.hopto.mjancola.utility.MySQLiteHelper.java
org.hopto.mjancola.utility.SettingsHelper.java
org.hopto.mjancola.utility.WorkoutDAO.java
org.hopto.mjancola.utility.WorkoutDataSource.java