private WeatherModular.OnWeatherCallBack onWeatherCallBack = new WeatherModular.OnWeatherCallBack() {        @Override
        public void onWeatherLiveSearched(LocalWeatherLive localWeatherLive) {
            Log.e("--城市--", "" + localWeatherLive.getCity());            Log.e("--天气--", "" + localWeatherLive.getWeather());            Log.e("--温度--", "" + localWeatherLive.getTemperature() + "");            Log.e("--日期--", "" + localWeatherLive.getReportTime());            Log.e("--日期--", "" + Tools.getMonth() + "月" + Tools.getDay() + "日" + " " + Tools.getDayOfWeek());            weather = localWeatherLive.getWeather();            temperature = localWeatherLive.getTemperature() + "";            trip = getOut(localWeatherLive.getWeather(), Integer.valueOf(localWeatherLive.getWindPower().replace("≤", "").replace("≥", ""))) ? "不宜出行" : "适宜出行";            Glide.with(getActivity()).load("http://api.map.baidu.com/images/weather/day/" + ChineseSpelling.getInstance().getSelling(localWeatherLive.getWeather()) + ".png").into(iv_home_weather);            tv_home_weather.setText(weather);            tv_home_city.setText(localWeatherLive.getCity());            tv_home_temperature.setText(temperature);//            tv_home_air.setText("空气质量:良");            tv_home_date.setText(Tools.getMonth() + "月" + Tools.getDay() + "日" + " " + Tools.getDayOfWeek());        }        @Override
        public void onWeatherForecastSearched(List<LocalDayWeatherForecast> weathers) {            int size = weathers.size() > 4 ? 4 : weathers.size();            boolean isNoOut = true;            for (int i = 1; i < size; i++) {                if (!(isNoOut = !getOut(weathers.get(i).getDayWeather(), Integer.valueOf(weathers.get(i).getDayWindPower().replace("≤", "").replace("≥", ""))))) {                    break;                }            }            car_wash = isNoOut ? "适宜洗车" : "不宜洗车";            //tv_home_clean_car.setText(car_wash);        }        private boolean getOut(String weather, int power) {            return weather.contains("雨") || weather.contains("雪") || weather.contains("雾") || weather.contains("尘") || weather.contains("沙") || weather.contains("飑") || weather.contains("风") || weather.contains("霾") || power > 6;        }
    };package com.lc.tyf.action;import android.content.Context;import com.amap.api.services.weather.LocalDayWeatherForecast;
import com.amap.api.services.weather.LocalWeatherForecastResult;
import com.amap.api.services.weather.LocalWeatherLive;
import com.amap.api.services.weather.LocalWeatherLiveResult;
import com.amap.api.services.weather.WeatherSearch;
import com.amap.api.services.weather.WeatherSearchQuery;import java.util.ArrayList;
import java.util.List;/**
 * Created by Administrator on 2016/5/11.
 */
public class WeatherModular implements WeatherSearch.OnWeatherSearchListener{    private WeatherSearch forcastsWeatherSearch, liveWeatherSearch;    private List<OnWeatherCallBack> callBacks = new ArrayList<>();    private LocalWeatherLive localWeatherLive;    private List<LocalDayWeatherForecast> weathers;    public WeatherModular(Context context){        forcastsWeatherSearch = new WeatherSearch(context);        forcastsWeatherSearch.setOnWeatherSearchListener(this);        liveWeatherSearch = new WeatherSearch(context);        liveWeatherSearch.setOnWeatherSearchListener(this);    }//    设置城市,查询实时天气及天气预报
    public void setCity(String city){        forcastsWeatherSearch.setQuery(new WeatherSearchQuery(city, WeatherSearchQuery.WEATHER_TYPE_FORECAST));        forcastsWeatherSearch.searchWeatherAsyn();        liveWeatherSearch.setQuery(new WeatherSearchQuery(city, WeatherSearchQuery.WEATHER_TYPE_LIVE));        liveWeatherSearch.searchWeatherAsyn();    }    @Override
    public void onWeatherLiveSearched(LocalWeatherLiveResult localWeatherLiveResult, int i) {        if (localWeatherLiveResult != null && localWeatherLiveResult.getLiveResult() != null) {            localWeatherLive = localWeatherLiveResult.getLiveResult();            forecastLiveBackAll();        }    }    @Override
    public void onWeatherForecastSearched(LocalWeatherForecastResult localWeatherForecastResult, int i) {        if (localWeatherForecastResult!=null && localWeatherForecastResult.getForecastResult()!=null
                && localWeatherForecastResult.getForecastResult().getWeatherForecast()!=null
                && localWeatherForecastResult.getForecastResult().getWeatherForecast().size()>0) {            weathers = localWeatherForecastResult.getForecastResult().getWeatherForecast();            forecastCallBackAll();        }    }    public void addOnWeatherCallBack(OnWeatherCallBack onWeatherCallBack){        if(!callBacks.contains(onWeatherCallBack) && onWeatherCallBack != null){            callBacks.add(onWeatherCallBack);            liveCallBack(onWeatherCallBack);            forecastCallBack(onWeatherCallBack);        }    }    public void removeOnWeatherCallBack(OnWeatherCallBack onWeatherCallBack){        if(!callBacks.contains(onWeatherCallBack) && onWeatherCallBack != null){            callBacks.remove(onWeatherCallBack);        }    }    private void liveCallBack(OnWeatherCallBack onWeatherCallBack){        if(localWeatherLive != null){            onWeatherCallBack.onWeatherLiveSearched(localWeatherLive);        }    }    private void forecastCallBack(OnWeatherCallBack onWeatherCallBack){        if(weathers != null){            onWeatherCallBack.onWeatherForecastSearched(weathers);        }    }    private void forecastLiveBackAll(){        for (int i = 0; i < callBacks.size(); i++){            liveCallBack(callBacks.get(i));        }    }    private void forecastCallBackAll(){        for (int i = 0; i < callBacks.size(); i++){            forecastCallBack(callBacks.get(i));        }    }    public static class OnWeatherCallBack{        public void onWeatherLiveSearched(LocalWeatherLive localWeatherLive){}        public void onWeatherForecastSearched(List<LocalDayWeatherForecast> weathers){}    }}