Android Open Source - EdmontonWifi Data






From Project

Back to project page EdmontonWifi.

License

The source code is released under:

MIT License

If you think the Android project EdmontonWifi 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 hey.rich.edmontonwifi.Objects;
//from   w  w w.j a  v  a2 s  .co  m
import android.location.Location;

/**
 * Created by chris on 17/08/14.
 */
public class Data {
    public final static float INVALID_DISTANCE = -1;

    /**
     * ID is a HEX value with dashes in it
     */
    private String id;
    /**
     * Name of the place where the WiFi antenna is located
     */
    private String name;
    /**
     * Physical street address where the WiFi antenna is located
     */
    private String address;

    /**
     * Spatial coordinates of location
     */
    private Location location;
    /**
     * Distance to a specified location
     */
    private double distance;

    public Data(String id, String name, String address, Location location) {
        this.id = id;
        this.name = name;
        this.address = address;
        this.location = location;

        // Set distance to invalid since we don't know what location we want
        // distance from
        this.distance = INVALID_DISTANCE;
    }

    /**
     * Returns a nicely formatted distance string for the given Wifi
     * Assumes that the distance to location is already set.
     */
    public static String getDistanceString(Data d) {
        double distance = d.getDistance();

        // Return invalid distance
        if (distance < 0) return "No distance available.";
        else if (distance < 500) {
            // Return distance in meters
            return String.format("Distance: %3.0f m", distance);
        } else { // distance >= 500
            // return distance in kms
            return String.format("Distance: %.1f km", distance / 1000);
        }
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }


    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    public void setDistanceToLocation(Location l) {
        this.distance = l.distanceTo(this.location);
    }

    public double getDistance() {
        return this.distance;
    }
}




Java Source Code List

hey.rich.edmontonwifi.EdmontonWifi.java
hey.rich.edmontonwifi.Objects.ConstructionList.java
hey.rich.edmontonwifi.Objects.Construction.java
hey.rich.edmontonwifi.Objects.Data.java
hey.rich.edmontonwifi.Objects.WifiList.java
hey.rich.edmontonwifi.Objects.Wifi.java
hey.rich.edmontonwifi.activities.ConstructionViewActivity.java
hey.rich.edmontonwifi.activities.MainActivity.java
hey.rich.edmontonwifi.activities.SearchActivity.java
hey.rich.edmontonwifi.activities.WifiViewActivity.java
hey.rich.edmontonwifi.adapters.ConstructionArrayAdapter.java
hey.rich.edmontonwifi.adapters.WifiArrayAdapter.java
hey.rich.edmontonwifi.fragments.ClearSearchHistoryDialogFragment.java
hey.rich.edmontonwifi.fragments.ConstructionFragment.java
hey.rich.edmontonwifi.fragments.NavigationDrawerFragment.java
hey.rich.edmontonwifi.fragments.SettingsFragment.java
hey.rich.edmontonwifi.fragments.WifiFragment.java
hey.rich.edmontonwifi.utils.JsonReader.java
hey.rich.edmontonwifi.utils.Sorters.java
hey.rich.edmontonwifi.utils.WifiSearchRecentSuggestionsProvider.java