/** Stops presenter if no data left (all removed) */ protected void stopIfEmpty() { if (data.getWorkouts().size() == 0 && data.getNutrition() == null && data.getMeasurements().size() == 0 && data.getCardios().size() == 0 && data.getRuns().size() == 0) { stop(); } }
/** Shows all data */ protected void showData() { try { unbindPresenters(); // workouts if (data.getWorkouts() != null) { for (WorkoutModel w : data.getWorkouts()) { // if only link if (showOnlyLinks) { final WorkoutLinkPresenter wp = new WorkoutLinkPresenter( rpcService, eventBus, (WorkoutLinkDisplay) GWT.create(WorkoutLinkView.class), w, false); addNewPresenter(wp); } else { final WorkoutPresenter wp = new WorkoutPresenter( rpcService, eventBus, (WorkoutDisplay) GWT.create(WorkoutView.class), w); addNewPresenter(wp); } } } // nutrition if (data.getNutrition() != null) { // if only link if (showOnlyLinks) { // set date data.getNutrition().setDate(CommonUtils.getDateGmt(data.getDate())); final NutritionDayLinkPresenter wp = new NutritionDayLinkPresenter( rpcService, eventBus, (NutritionDayLinkDisplay) GWT.create(NutritionDayLinkView.class), data.getNutrition()); addNewPresenter(wp); } else { final NutritionDayPresenter wp = new NutritionDayPresenter( rpcService, eventBus, (NutritionDayDisplay) GWT.create(NutritionDayView.class), data.getUser().getUid(), CommonUtils.getDateGmt(data.getDate()), data.getNutrition()); addNewPresenter(wp); } } if (data.getMeasurements() != null) { // measurement for (MeasurementValueModel m : data.getMeasurements()) { final MeasurementValueLinkPresenter wp = new MeasurementValueLinkPresenter( rpcService, eventBus, (MeasurementValueLinkDisplay) GWT.create(MeasurementValueLinkView.class), m); addNewPresenter(wp); } } // cardio if (data.getCardios() != null) { for (CardioValueModel m : data.getCardios()) { final CardioValueLinkPresenter wp = new CardioValueLinkPresenter( rpcService, eventBus, (CardioValueLinkDisplay) GWT.create(CardioValueLinkView.class), m); addNewPresenter(wp); } } // run if (data.getRuns() != null) { for (RunValueModel m : data.getRuns()) { final RunValueLinkPresenter wp = new RunValueLinkPresenter( rpcService, eventBus, (RunValueLinkDisplay) GWT.create(RunValueLinkView.class), m); addNewPresenter(wp); } } } catch (Exception e) { Motiver.showException(e); } }