Android Open Source - EdmontonWifi Edmonton Wifi






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;
/*  w w  w  .  j a v  a2  s. co m*/
import android.app.Application;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;

import java.util.List;

import hey.rich.edmontonwifi.Objects.Construction;
import hey.rich.edmontonwifi.Objects.ConstructionList;
import hey.rich.edmontonwifi.Objects.Wifi;
import hey.rich.edmontonwifi.Objects.WifiList;
import hey.rich.edmontonwifi.utils.JsonReader;

/**
 * Singleton Class
 */
public class EdmontonWifi extends Application {

    private static final String WIFI_FILE_NAME = "wifi.json";
    private static final String CONSTRUCTION_FILE_NAME = "construction.json";

    private static WifiList wifiList = null;
    private static ConstructionList constructionList = null;

    /**
     * Returns the wifiList, if one doesn't exist, we will create it here.
     */
    public static WifiList getWifiList(Context context) {
        if (wifiList == null) {
            // load wifilist
            wifiList = new WifiList();
            wifiList.setAllWifis(JsonReader.jsonStringToWifiList(JsonReader
                    .loadJSONFromAsset(context.getAssets(), WIFI_FILE_NAME)));
        }

        return wifiList;
    }

    public static ConstructionList getConstructionList(Context context) {
        if (constructionList == null) {
            // load constructionList
            constructionList = new ConstructionList();
            constructionList.setAllConstructions(JsonReader.jsonStringToConstructionList(JsonReader.
                    loadJSONFromAsset(context.getAssets(), CONSTRUCTION_FILE_NAME)));
        }

        return constructionList;
    }

    public static Wifi getWifi(Context context, int position) {
        if (wifiList == null) {
            wifiList = getWifiList(context);
        }

        return wifiList.getWifiAtPos(position);
    }

    public static Construction getConstruction(Context context, int position){
        if(constructionList == null){
            constructionList = getConstructionList(context);
        }
        return constructionList.getConstructionAtPos(position);
    }


    /**
     * Gets the last known location of the device.
     * If this can't be found for some reason, null will be returned.
     */
    public static Location getLocation(Context context) {
        // From: http://stackoverflow.com/a/20465781/1684866
        LocationManager manager = (LocationManager) context.getSystemService(LOCATION_SERVICE);

        List<String> providers = manager.getProviders(true);
        Location bestLocation = null;

        for (String provider : providers) {
            Location l = manager.getLastKnownLocation(provider);

            if (l == null) {
                continue;
            }
            if (bestLocation == null || l.getAccuracy() < bestLocation.getAccuracy()) {
                bestLocation = l;
            }
        }
        return bestLocation;
    }
}




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