(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++;
}
}
fromStartingPoint += notCounter;
if (notCounter >= quantity) { //there could be more notifications
showMoreNotificationsPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
showMoreWidget = new ShowMoreNotifications();
showMoreNotificationsPanel.clear();
showMoreNotificationsPanel.add(showMoreWidget);
mainPanel.add(showMoreNotificationsPanel);
}
lockNotificationUpdate = false;
}
}
@Override
public void onFailure(Throwable caught) {
showMoreNotificationsPanel.clear();
mainPanel.add(new HTML("" +
"Ops! There were problems while retrieving your Notifications!.
" +
"Please try again in a short while.
"));
}
});
}
/**
* @param widget the widget to check
* @returnn true if the widget is in the visible part of the page
*/
private boolean isScrolledIntoView(Widget widget) {
if (widget != null) {
int docViewTop = Window.getScrollTop();
int docViewBottom = docViewTop + Window.getClientHeight();
int elemTop = widget.getAbsoluteTop();
int elemBottom = elemTop + widget.getOffsetHeight();
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
return false;
}
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);
}
}