예제 #1
0
 @Override
 public void onLocationUpdate(LocationInfo location, long costTime, int locator) {
   if (location == null) {
     return;
   }
   latitude = location.getLatitude();
   longitude = location.getLongitude();
   locationName = location.toString();
   userPrefs.setCurrentLocation(longitude, latitude, locationName);
   locationTextView.setText(String.format("%s (%.3f, %.3f)", locationName, longitude, latitude));
   weatherUpdated = false;
   satelliteUpdated = false;
   StatManager.getInstance().sendLocationStat(location, costTime, locator);
   updateButton.performClick();
 }
예제 #2
0
 @Override
 public void onTaskFinished(Object sender, TaskFinishedEvent event) {
   Log.d("deepsky", "Task finished");
   TaskContext taskContext = event.getContext();
   String response = (String) taskContext.get(WeatherTask.KEY_RESULT);
   long totalDelay =
       (Long) taskContext.get(Task.KEY_END_TIME)
           - (Long) taskContext.get(Task.KEY_START_TIME);
   long serverDelay = -1;
   try {
     JSONObject jsonObject = new JSONObject(response);
     serverDelay = jsonObject.getLong("delay");
     createWeatherView(jsonObject.getJSONObject("data"), true);
   } catch (JSONException e) {
     Toast.makeText(getApplicationContext(), R.string.toast_data_error, Toast.LENGTH_SHORT)
         .show();
   } finally {
     refreshDialog.dismiss();
   }
   StatManager.getInstance().sendWeatherStat(totalDelay, serverDelay);
 }
예제 #3
0
 @Override
 public void onTaskFinished(Object sender, TaskFinishedEvent event) {
   Log.d("deepsky", "Task finished");
   TaskContext taskContext = event.getContext();
   String response = (String) taskContext.get(SatelliteTask.KEY_RESULT);
   long delay =
       (Long) taskContext.get(Task.KEY_END_TIME)
           - (Long) taskContext.get(Task.KEY_START_TIME);
   cacheManager.createSatelliteCache(longitude, latitude, response);
   try {
     JSONObject data = new JSONObject(response);
     SatelliteView sv = new SatelliteView(context, satelliteView);
     sv.setData(data);
     satelliteUpdated = true;
   } catch (JSONException e) {
     Toast.makeText(context, R.string.toast_data_error, Toast.LENGTH_SHORT).show();
   } finally {
     refreshDialog.dismiss();
   }
   StatManager.getInstance().sendSatelliteStat(delay);
 }
예제 #4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    this.context = this;
    this.cacheManager = CacheManager.getInstance(context);
    this.reportMode = MODE_WEATHER;
    this.exitTime = 0L;

    this.reportsViewPager = (CustomerViewPager) findViewById(R.id.viewpager_reports);
    this.updateButton = (ImageButton) findViewById(R.id.button_update);
    this.locationButton = (ImageButton) findViewById(R.id.button_location);
    this.settingsButton = (ImageButton) findViewById(R.id.button_settings);
    this.switchReportButton = (ImageButton) findViewById(R.id.button_switch_report);
    this.updatetimeTextView = (TextView) findViewById(R.id.textview_updatetime);
    this.locationTextView = (TextView) findViewById(R.id.textview_location);

    LayoutInflater inflater = LayoutInflater.from(context);
    weatherView = inflater.inflate(R.layout.linearlayout_weather, null);
    satelliteView = inflater.inflate(R.layout.linearlayout_satellite, null);
    this.forecastScrollView =
        (HorizontalScrollView) weatherView.findViewById(R.id.scrollview_forecast);
    this.templabelTextView = (TextView) weatherView.findViewById(R.id.textview_templabel);

    reportsViewList = new ArrayList<View>();
    reportsViewList.add(weatherView);
    reportsViewList.add(satelliteView);

    reportsViewPager.setScrollable(false);
    reportsViewPager.setSwitchDuration(700);
    reportsViewPager.setAdapter(pagerAdapter);

    this.refreshDialog = DialogManager.createRefreshDialog(context);
    loadSettings();
    StatManager.getInstance().sendStartApp(null);
    UmengUpdateAgent.update(this);
  }