Android Open Source - YahooWeather Location Getter






From Project

Back to project page YahooWeather.

License

The source code is released under:

GNU General Public License

If you think the Android project YahooWeather 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 com.imlongluo.weather.lbs;
//from  www. jav a  2 s .c  o  m
import android.util.Log;

import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;

public class LocationGetter {
    private static final String TAG = LocationGetter.class.getSimpleName();

    public class LocationListener implements BDLocationListener {

        @Override
        public void onReceiveLocation(BDLocation location) {
            // Receive Location
            StringBuffer sb = new StringBuffer(256);
            sb.append("time : ");
            sb.append(location.getTime());
            sb.append("\nerror code : ");
            sb.append(location.getLocType());
            sb.append("\nlatitude : ");
            sb.append(location.getLatitude());
            sb.append("\nlontitude : ");
            sb.append(location.getLongitude());
            sb.append("\nradius : ");
            sb.append(location.getRadius());
            if (location.getLocType() == BDLocation.TypeGpsLocation) {
                sb.append("\nspeed : ");
                sb.append(location.getSpeed());
                sb.append("\nsatellite : ");
                sb.append(location.getSatelliteNumber());
                sb.append("\ndirection : ");
                sb.append(location.getDirection());
            } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {
                sb.append("\naddr : ");
                sb.append(location.getAddrStr());
                //
                sb.append("\noperationers : ");
                sb.append(location.getOperators());
            }
            Log.i(TAG, "BD return: " + sb.toString());

            String city = location.getCity();
            String district = location.getDistrict();
            Log.i(TAG, "BD return city: " + city);
            Log.i(TAG, "BD return district: " + district);

            if ((city != null) && !city.equals("")) {
                String locateAddr = "";
                if ((district == null) || (district.equals(""))) {
                    locateAddr = deleteSuffix(city);
                } else {
//                    locateAddr = filterResult(city, district);
                }

//                waitAndPostRusultToUIHandler(MSG_GETCITY_SUCCESS, locateAddr);
            }
        }

    }
/*    private String filterResult(String city, String district) {
        boolean isMunicipaty = false;
        String locateAddress = "";
        String xian = mContext.getString(R.string.sheng);
        String qu = mContext.getString(R.string.qu);
        String[] municipalities = mContext.getResources().getStringArray(R.array.Municipalities);
        int municipalityLength = municipalities.length;

        String[] specialLocateAddress = mContext.getResources().getStringArray(
                R.array.special_locate_address);
        int specialLocateAddressLength = specialLocateAddress.length;

        String[] upperCitySpecialLocateAddress = mContext.getResources().getStringArray(
                R.array.upper_city_special_locate_address);

        for (int i = 0; i < municipalityLength; i++) {
            if (municipalities[i].equals(city)) {
                locateAddress = city;
                isMunicipaty = true;
                break;
            }
        }

        if (!isMunicipaty) {
            for (int i = 0; i < specialLocateAddressLength; i++) {
                if (district.startsWith(specialLocateAddress[i])) {
                    locateAddress = upperCitySpecialLocateAddress[i];
                    isMunicipaty = true;

                    break;
                }
            }
        }

        if (!isMunicipaty) {
            if (city.contains(xian)) {
                locateAddress = district;
            } else {
                if (!district.endsWith(qu)) {
                    locateAddress = district;
                } else {
                    locateAddress = city;
                }
            }
        }

        if (locateAddress.length() > 2) {
            locateAddress = deleteSuffix(locateAddress);
        }

        return locateAddress;
    }*/

    private String deleteSuffix(String string) {
        int length = string.length();
        string = string.substring(0, length - 1);
        return string;
    }

}




Java Source Code List

cn.sharesdk.demo.wxapi.WXEntryActivity.java
cn.sharesdk.onekeyshare.CustomerLogo.java
cn.sharesdk.onekeyshare.EditPage.java
cn.sharesdk.onekeyshare.FollowList.java
cn.sharesdk.onekeyshare.OnekeyShare.java
cn.sharesdk.onekeyshare.PicViewer.java
cn.sharesdk.onekeyshare.PlatformGridView.java
cn.sharesdk.onekeyshare.Shake2Share.java
cn.sharesdk.onekeyshare.ShareContentCustomizeCallback.java
cn.sharesdk.onekeyshare.ShareCore.java
com.imlongluo.weather.MainActivity.java
com.imlongluo.weather.WeatherApplication.java
com.imlongluo.weather.apis.AsciiUtils.java
com.imlongluo.weather.apis.ImageUtils.java
com.imlongluo.weather.apis.NetworkUtils.java
com.imlongluo.weather.apis.UserLocationUtils.java
com.imlongluo.weather.apis.WOEIDInfo.java
com.imlongluo.weather.apis.WOEIDUtils.java
com.imlongluo.weather.apis.WeatherInfo.java
com.imlongluo.weather.apis.YahooWeatherConsts.java
com.imlongluo.weather.apis.YahooWeatherExceptionListener.java
com.imlongluo.weather.apis.YahooWeatherInfoListener.java
com.imlongluo.weather.apis.YahooWeatherLog.java
com.imlongluo.weather.apis.YahooWeather.java
com.imlongluo.weather.lbs.LocationGetter.java
com.imlongluo.weather.lbs.LocationManagerActivity.java
com.imlongluo.weather.settings.SettingsActivity.java
com.imlongluo.weather.share.ShareActivity.java
com.imlongluo.weather.utils.Constants.java
com.imlongluo.weather.utils.Utils.java