Esempio n. 1
0
 /** 解析和处理服务器返回的省级数据 */
 public static synchronized boolean handleProvinceResponse(
     NiceWeatherDB coolWeatherDB, String response) {
   if (!TextUtils.isEmpty(response)) {
     String[] allProvince = response.split(",");
     if (allProvince != null && allProvince.length > 0) {
       for (String p : allProvince) {
         String[] array = p.split("\\|");
         Province province = new Province();
         province.setProvinceCode(array[0]);
         province.setProvinceName(array[1]);
         // 将解析出来的数据存储到Province表
         coolWeatherDB.saveProvince(province);
       }
       return true;
     }
   }
   return false;
 }
Esempio n. 2
0
 /** 解析和处理服务器返回的县级数据 */
 public static boolean handleCountiesResponse(
     NiceWeatherDB coolWeatherDB, String response, int cityId) {
   if (!TextUtils.isEmpty(response)) {
     String[] allCounties = response.split(",");
     if (allCounties != null && allCounties.length > 0) {
       for (String c : allCounties) {
         String[] array = c.split("\\|");
         County county = new County();
         county.setCountyCode(array[0]);
         county.setCountyName(array[1]);
         county.setCityId(cityId);
         // 将解析出来的数据存储到County表
         coolWeatherDB.saveCounty(county);
       }
       return true;
     }
   }
   return false;
 }