Search in sources :

Example 1 with AreaModel

use of tk.woppo.sunday.model.city.AreaModel in project SunDay by iQuick.

the class HomeFragment method getDataFromDB.

/**
     * 从数据库中获取数据
     */
@Background
void getDataFromDB() {
    for (AreaModel model : App.getMyArea()) {
        WeatherModel weatherModel = mWeatherDB.query(model.getWeatherCode());
        WeatherTodayModel weatherTodayModel = mTodayDB.query(model.getWeatherCode());
        if (weatherModel != null) {
            mWeatherModels.add(weatherModel);
            mSimpleWeatherModels.add(weatherModel.toSimpleWeatherList());
        }
        if (weatherTodayModel != null)
            mWeatherTodayModels.add(weatherTodayModel);
    }
    // 更新列表
    updateWeatherList();
}
Also used : WeatherTodayModel(tk.woppo.sunday.model.WeatherTodayModel) SimpleWeatherModel(tk.woppo.sunday.model.SimpleWeatherModel) CurWeatherModel(tk.woppo.sunday.model.CurWeatherModel) WeatherModel(tk.woppo.sunday.model.WeatherModel) AreaModel(tk.woppo.sunday.model.city.AreaModel) Background(org.androidannotations.annotations.Background)

Example 2 with AreaModel

use of tk.woppo.sunday.model.city.AreaModel in project SunDay by iQuick.

the class App method removeMyArea.

/**
     * 删除城市信息
     * @param position
     * @return
     */
public static AreaModel removeMyArea(int position) {
    // 删除数据
    AreaModel model = mAreaModels.remove(position);
    // 重新保存文件
    FileUtil.writeObjsToFile(mAreaModels, Const.FILE_MY_AREA, Context.MODE_PRIVATE);
    return model;
}
Also used : AreaModel(tk.woppo.sunday.model.city.AreaModel)

Example 3 with AreaModel

use of tk.woppo.sunday.model.city.AreaModel in project SunDay by iQuick.

the class App method addMyArea.

/**
     * 添加我的城市
     * @param model
     * @return
     */
public static String addMyArea(AreaModel model) {
    if (model == null) {
        LogUtil.i(TAG, "null");
        return null;
    }
    if (mAreaModels.size() >= 5) {
        return getContext().getString(R.string.city_exceed_num);
    } else {
        for (AreaModel areaModel : mAreaModels) {
            if (areaModel.getCityId().equals(model.getCityId())) {
                return getContext().getString(R.string.city_already_exists);
            }
        }
        //添加到第一位
        mAreaModels.add(0, model);
        // 重新保存文件
        FileUtil.writeObjsToFile(mAreaModels, Const.FILE_MY_AREA, Context.MODE_PRIVATE);
        // 返回添加城市结果信息
        return getContext().getString(R.string.city_add_success);
    }
}
Also used : AreaModel(tk.woppo.sunday.model.city.AreaModel)

Example 4 with AreaModel

use of tk.woppo.sunday.model.city.AreaModel in project SunDay by iQuick.

the class SplashActivity method isFrast.

private void isFrast() {
    if (SharedPrefUtil.isFrast()) {
        SharedPrefUtil.putBoolean(Const.CONFIG_AUTO_UPDATE, true);
        //添加一个默认城市-北京
        App.addMyArea(new AreaModel(Const.DEF_CITY_ID, Const.DEF_CITY_NAME, Const.DEF_WEATHER_CODE));
        //进入引导界面
        start(GuideActivity_.class);
    } else {
        //进入应用主界面
        start(MainActivity_.class);
    }
}
Also used : AreaModel(tk.woppo.sunday.model.city.AreaModel)

Example 5 with AreaModel

use of tk.woppo.sunday.model.city.AreaModel in project SunDay by iQuick.

the class CitySaxParseHandler method startElement.

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    super.startElement(uri, localName, qName, attributes);
    //        LogUtil.i(TAG, "start read tag - " + localName);
    this.tagName = localName;
    if (tagName.equalsIgnoreCase("province")) {
        //省
        mProvicneModel = new ProvicneModel();
        mProvicneModel.setCityName(attributes.getValue("name"));
        mProvicneModel.setCityId(attributes.getValue("id"));
    } else if (tagName.equalsIgnoreCase("city")) {
        //市
        mCityModel = new CityModel();
        mCityModel.setCityName(attributes.getValue("name"));
        mCityModel.setCityId(attributes.getValue("id"));
    } else if (tagName.equalsIgnoreCase("county")) {
        //区/县
        mAreaModel = new AreaModel();
        mAreaModel.setCityName(attributes.getValue("name"));
        mAreaModel.setCityId(attributes.getValue("id"));
        mAreaModel.setWeatherCode(attributes.getValue("weatherCode"));
    }
}
Also used : ProvicneModel(tk.woppo.sunday.model.city.ProvicneModel) CityModel(tk.woppo.sunday.model.city.CityModel) AreaModel(tk.woppo.sunday.model.city.AreaModel)

Aggregations

AreaModel (tk.woppo.sunday.model.city.AreaModel)5 Background (org.androidannotations.annotations.Background)1 CurWeatherModel (tk.woppo.sunday.model.CurWeatherModel)1 SimpleWeatherModel (tk.woppo.sunday.model.SimpleWeatherModel)1 WeatherModel (tk.woppo.sunday.model.WeatherModel)1 WeatherTodayModel (tk.woppo.sunday.model.WeatherTodayModel)1 CityModel (tk.woppo.sunday.model.city.CityModel)1 ProvicneModel (tk.woppo.sunday.model.city.ProvicneModel)1