> notificationsPerDay) {
notificationSettings.setVisible(true);
if (notificationsPerDay != null) {
mainPanel.clear();
if (notificationsPerDay.size() == 0) {
mainPanel.add(new HTML("" +
"Looks like we've got nothing for you at the moment.
" +
"You may begin by sharing an update!
"));
}
else {
mainPanel.setHeight("");
mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
ArrayList sortedKeys=new ArrayList(notificationsPerDay.keySet());
Collections.sort(sortedKeys, Collections.reverseOrder());
int notCounter = 0;
for (Date day : sortedKeys) {
mainPanel.add(new DayWrapper(day));
for (Notification notif : notificationsPerDay.get(day)) {
mainPanel.add(new SingleNotificationView(notif));
notCounter++;
}
}
setNotificationsRead();
if (notCounter < 5) {
mainPanel.add(new Image(spacer));
mainPanel.add(new Image(spacer));
}
if (notCounter > 5 && notCounter < 10)
mainPanel.add(new Image(spacer));
}
}
else
loadingImage.setUrl(warning);
}
});
}
private void showLoader() {
mainPanel.clear();
mainPanel.setWidth("100%");
mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
mainPanel.add(loadingImage);
}
private void showSettingsLoader(boolean show) {
if (show) {
loadingPanel.setWidth("100%");
loadingPanel.getElement().getStyle().setPosition(Position.ABSOLUTE);
loadingPanel.getElement().getStyle().setTop(mainPanel.getAbsoluteTop()+200, Unit.PX);
loadingPanel.getElement().getStyle().setLeft(mainPanel.getAbsoluteLeft(), Unit.PX);
loadingPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
loadingPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
loadingPanel.add(loadingImage);
mainPanel.add(loadingPanel);
} else
mainPanel.remove(loadingPanel);
}
Timer t;
private void setNotificationsRead() {
t = new Timer() {
@Override
public void run() {
notificationService.setAllUserNotificationsRead(new AsyncCallback() {
public void onFailure(Throwable caught) {
}
public void onSuccess(Boolean result) {
}
});
}
};
t.schedule(500);
}
}