Android Open Source - RazorRunner-AndroidProject Distance Notifier






From Project

Back to project page RazorRunner-AndroidProject.

License

The source code is released under:

Apache License

If you think the Android project RazorRunner-AndroidProject 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 edu.uark.csce.razorrunner;
// w w w  .j av a  2 s  .co  m
/**
 * Created by Kai Tribble on 12/3/2014.
 */
public class DistanceNotifier implements StepListener{

    public interface Listener {
        public void valueChanged(float value);
        public void passValue();
    }
    private Listener mListener;

    float mDistance = 0;

    PedometerSettings mSettings;
    ActivityUtils mUtils;

    boolean mIsMetric;
    float mStepLength;


    public DistanceNotifier(Listener listener, PedometerSettings settings, ActivityUtils utils) {
        mListener = listener;
        mUtils = utils;
        mSettings = settings;
        reloadSettings();
    }
    public void setDistance(float distance) {
        mDistance = distance;
        notifyListener();
    }

    public void reloadSettings() {
        mIsMetric = mSettings.isMetric();
        mStepLength = mSettings.getStepLength();
        notifyListener();
    }

    public void onStep() {

        if (mIsMetric) {
            mDistance += (float)(// kilometers
                    mStepLength // centimeters
                            / 100000.0); // centimeters/kilometer
        }
        else {
            mDistance += (float)(// miles
                    mStepLength // inches
                            / 63360.0); // inches/mile
        }

        notifyListener();
    }

    private void notifyListener() {
        mListener.valueChanged(mDistance);
    }

    @Override
    public void passValue() {

    }
}




Java Source Code List

edu.uark.csce.razorrunner.ActivityUtils.java
edu.uark.csce.razorrunner.BuildConfig.java
edu.uark.csce.razorrunner.DistanceNotifier.java
edu.uark.csce.razorrunner.HistoryActivity.java
edu.uark.csce.razorrunner.Manifest.java
edu.uark.csce.razorrunner.OverviewActivity.java
edu.uark.csce.razorrunner.PedometerSettings.java
edu.uark.csce.razorrunner.ProfileActivity.java
edu.uark.csce.razorrunner.RemoveDetection.java
edu.uark.csce.razorrunner.RequestDetection.java
edu.uark.csce.razorrunner.StepDetector.java
edu.uark.csce.razorrunner.StepDisplayer.java
edu.uark.csce.razorrunner.StepListener.java
edu.uark.csce.razorrunner.UserActivityRecognition.java
edu.uark.csce.razorrunner.UserSettingsActivity.java
edu.uark.csce.razorrunner.UserStepRecognition.java
edu.uark.csce.razorrunner.WorkoutActivity.java
edu.uark.csce.razorrunner.WorkoutContentProvider.java
edu.uark.csce.razorrunner.WorkoutData.java
edu.uark.csce.razorrunner.WorkoutItemAdapter.java