private void checkAddCity() {
   if (WeatherData.getCityInfo(0).mShowType
       == com.moji.mjweather.data.CityWeatherInfo.ShowType.ST_NOSET) {
     Gl.setHandler(MainHandler);
     Intent intent = new Intent(this, AddCityActivity.class);
     Bundle bundle = new Bundle();
     bundle.putInt("cityindex", 0);
     bundle.putBoolean("isNoDisplayLocation", true);
     intent.putExtras(bundle);
     startActivity(intent);
   }
 }
  public static void main(String[] args) {
    WeatherData weatherData = new WeatherData();
    CurrentConditionsDisplay currentDisplay = new CurrentConditionsDisplay(weatherData);
    StatisticsDisplay statisticsDisplay = new StatisticsDisplay(weatherData);
    ForecastDisplay forecastDisplay = new ForecastDisplay(weatherData);
    HeatIndexDisplay heatIndexDisplay = new HeatIndexDisplay(weatherData);

    weatherData.setMeasurements(80, 65, 30.4f);
    weatherData.setMeasurements(82, 70, 29.2f);
    weatherData.setMeasurements(78, 90, 29.2f);
  }
 private void doIntentCityManager() {
   if (WeatherData.getCityInfo(Gl.getCurrentCityIndex()).mShowType
       == com.moji.mjweather.data.CityWeatherInfo.ShowType.ST_UPDATING) {
     Toast.makeText(this, 0x7f0b0041, 0).show();
   } else {
     Gl.setChangedCity(false);
     startActivityForResult(new Intent(this, CityManagerActivity.class), 99);
   }
 }
 private void doBroadcast() {
   if (WeatherData.getCityInfo(Gl.getCurrentCityIndex()).mShowType
       == com.moji.mjweather.data.CityWeatherInfo.ShowType.ST_NOSET) {
     mCDialogManager.showNotifyAddCityDialog();
   } else {
     // PlayerUtil.manualBroadcast(mCDialogManager, MainHandler);
     if (PlayerUtil.isBroadcasting) mBroadcast.setImageResource(0x7f02014b);
     else mBroadcast.setImageResource(0x7f02014a);
   }
 }
 private void doAddCityResult(Message message) {
   int i = 0;
   while (i < 9) {
     if (WeatherData.getCityInfo(i).m_cityID == message.arg2) {
       mCDialogManager.CancelCurrentDialog();
       if (message.arg2 != -1) mCDialogManager.ShowMsgOKDialog(0x7f0b0035);
       else mCDialogManager.ShowMsgOKDialog(0x7f0b003f);
     }
     i++;
   }
   CityWeatherInfo cityweatherinfo = WeatherData.getCityInfo(message.arg1);
   cityweatherinfo.Clean();
   cityweatherinfo.m_cityID = message.arg2;
   cityweatherinfo.mCityName = message.obj.toString();
   cityweatherinfo.mShowType = com.moji.mjweather.data.CityWeatherInfo.ShowType.ST_NEED_BE_UPDATE;
   cityweatherinfo.mWeatherMainInfo.mWeatherDescription = "";
   cityweatherinfo.m_lastUpdateTime = "";
   Gl.saveCityInfo(message.arg1, cityweatherinfo);
   Gl.saveCurrentCityIndex(message.arg1);
 }
 private void startUpdateWeather() {
   mUpdateWeather.setImageResource(0x7f02014f);
   isUpdating = true;
   if (mUpdateCallbackImpl == null) mUpdateCallbackImpl = new UpdateCallbackImpl();
   WeatherPublisher.getInstance().unSubscribe(mUpdateCallbackImpl);
   WeatherPublisher.getInstance().subscribe(mUpdateCallbackImpl);
   if (mWeatherUpdater == null) mWeatherUpdater = AbstractWeatherUpdater.createInstance();
   mWeatherUpdater.update(Gl.getCurrentCityIndex());
   WeatherData.getCityInfo(Gl.getCurrentCityIndex()).mShowType =
       com.moji.mjweather.data.CityWeatherInfo.ShowType.ST_UPDATING;
   mUpdateLayout.setVisibility(0);
   if (mPublicTextView != null) mPublicTextView.setVisibility(8);
 }
 private void doUpdateResult(com.moji.mjweather.common.WeatherUpdater.Result result) {
   if (AbstractWeatherUpdater.isSucceed(result)) {
     CityWeatherInfo cityweatherinfo = WeatherData.getCityInfo(result.cityIndex);
     Gl.Ct()
         .deleteFile(
             (new StringBuilder()).append(cityweatherinfo.m_cityID).append(".txt").toString());
     mWorkSpace.replaceCity(Gl.getCurrentCityIndex(), false);
     Gl.setNeedNotifyTrendState(true);
   } else {
     mCDialogManager.CancelCurrentDialog();
     mCDialogManager.ShowMsgOKDialogFromString((String) result.errMsg);
   }
   cancelUpdateWeather(null, false);
 }
 private void cancelUpdateWeather(CityWeatherInfo cityweatherinfo, boolean flag) {
   if (cityweatherinfo == null)
     cityweatherinfo = WeatherData.getCityInfo(Gl.getCurrentCityIndex());
   mUpdateWeather.setImageResource(0x7f02014e);
   isUpdating = false;
   Gl.setIsLocationbyGPS(false);
   if (mWeatherUpdater != null) mWeatherUpdater.cancel();
   if (mUpdateCallbackImpl != null)
     WeatherPublisher.getInstance().unSubscribe(mUpdateCallbackImpl);
   mUpdateLayout.setVisibility(8);
   if (mPublicTextView != null) mPublicTextView.setVisibility(0);
   if (cityweatherinfo.mShowType == com.moji.mjweather.data.CityWeatherInfo.ShowType.ST_UPDATING)
     if (cityweatherinfo.m_lastUpdateTime.length() <= 0)
       cityweatherinfo.mShowType =
           com.moji.mjweather.data.CityWeatherInfo.ShowType.ST_NEED_BE_UPDATE;
     else cityweatherinfo.mShowType = com.moji.mjweather.data.CityWeatherInfo.ShowType.ST_OK;
   if (flag) Toast.makeText(this, 0x7f0b0039, 0).show();
 }
 private void doUpdateCityWeather(boolean flag) {
   CityWeatherInfo cityweatherinfo = WeatherData.getCityInfo(Gl.getCurrentCityIndex());
   if ((!flag
           || cityweatherinfo.mShowType
               == com.moji.mjweather.data.CityWeatherInfo.ShowType.ST_NEED_BE_UPDATE)
       && cityweatherinfo.mShowType != com.moji.mjweather.data.CityWeatherInfo.ShowType.ST_NOSET)
     if (!Util.isConnectInternet(this)) {
       mCDialogManager.CancelCurrentDialog();
       mCDialogManager.ShowMsgOKDialog(0x7f0b0032);
     } else {
       mUpdateLayout =
           (LinearLayout)
               mWorkSpace.getChildAt(mWorkSpace.getCurrentScreen()).findViewById(0x7f0d0106);
       if (cityweatherinfo.mShowType == com.moji.mjweather.data.CityWeatherInfo.ShowType.ST_OK)
         mPublicTextView =
             (TextView)
                 mWorkSpace.getChildAt(mWorkSpace.getCurrentScreen()).findViewById(0x7f0d0117);
       if (isUpdating) cancelUpdateWeather(cityweatherinfo, true);
       else startUpdateWeather();
     }
 }
Beispiel #10
0
 public StatisticsDisplay(WeatherData weatherData) {
   this.weatherData = weatherData;
   weatherData.registerObserver(this);
 }