fixed bug multiple requests with same range
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/notifications@94134 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cc0c43afe0
commit
23c4798335
|
@ -54,6 +54,8 @@ public class NotificationsPanel extends Composite {
|
|||
private ShowMoreNotifications showMoreWidget;
|
||||
//needed to know the next range start
|
||||
private int fromStartingPoint = 0;
|
||||
//needed to avoid to call the doShowMoreNotifications when the forst call has not returned yet
|
||||
private boolean lockNotificationUpdate = false;
|
||||
|
||||
private VerticalPanel container = new VerticalPanel();
|
||||
private HorizontalPanel settingsPanel = new HorizontalPanel();
|
||||
|
@ -120,8 +122,9 @@ public class NotificationsPanel extends Composite {
|
|||
@Override
|
||||
public void onWindowScroll(ScrollEvent event) {
|
||||
boolean isInView = isScrolledIntoView(showMoreWidget);
|
||||
if (isInView) {
|
||||
if (isInView && !lockNotificationUpdate) {
|
||||
doShowMoreNotifications();
|
||||
lockNotificationUpdate = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -189,13 +192,14 @@ public class NotificationsPanel extends Composite {
|
|||
/**
|
||||
* called when a user scroll down the page to the bottom
|
||||
*/
|
||||
private void doShowMoreNotifications() {
|
||||
private void doShowMoreNotifications() {
|
||||
GWT.log("doShowMoreNotifications()");
|
||||
showMoreNotificationsPanel.remove(0);
|
||||
loadingImage.getElement().getStyle().setMargin(10, Unit.PX);
|
||||
showMoreNotificationsPanel.add(loadingImage);
|
||||
int from = (fromStartingPoint == 0) ? NotificationConstants.NOTIFICATION_NUMBER+1 : fromStartingPoint;
|
||||
fromStartingPoint = from;
|
||||
final int quantity = 20;
|
||||
final int quantity = 10;
|
||||
GWT.log("StartingPoint = " + from);
|
||||
|
||||
notificationService.getUserNotificationsByRange(from, quantity, new AsyncCallback<HashMap<Date,ArrayList<Notification>>>() {
|
||||
|
@ -220,9 +224,11 @@ public class NotificationsPanel extends Composite {
|
|||
GWT.log("Show MORE ");
|
||||
showMoreNotificationsPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
|
||||
showMoreWidget = new ShowMoreNotifications();
|
||||
showMoreNotificationsPanel.clear();
|
||||
showMoreNotificationsPanel.add(showMoreWidget);
|
||||
mainPanel.add(showMoreNotificationsPanel);
|
||||
}
|
||||
lockNotificationUpdate = false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -54,7 +54,7 @@ a.link:hover {
|
|||
.new-notifications-show {
|
||||
opacity: 1;
|
||||
background: #D6E2FC;
|
||||
height: 18px;
|
||||
height: 38px;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue