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();
}
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;
}
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);
}
}
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);
}
}
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"));
}
}
Aggregations