コード例 #1
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);
 }
コード例 #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);
 }