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;
|
private ShowMoreNotifications showMoreWidget;
|
||||||
//needed to know the next range start
|
//needed to know the next range start
|
||||||
private int fromStartingPoint = 0;
|
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 VerticalPanel container = new VerticalPanel();
|
||||||
private HorizontalPanel settingsPanel = new HorizontalPanel();
|
private HorizontalPanel settingsPanel = new HorizontalPanel();
|
||||||
|
@ -120,8 +122,9 @@ public class NotificationsPanel extends Composite {
|
||||||
@Override
|
@Override
|
||||||
public void onWindowScroll(ScrollEvent event) {
|
public void onWindowScroll(ScrollEvent event) {
|
||||||
boolean isInView = isScrolledIntoView(showMoreWidget);
|
boolean isInView = isScrolledIntoView(showMoreWidget);
|
||||||
if (isInView) {
|
if (isInView && !lockNotificationUpdate) {
|
||||||
doShowMoreNotifications();
|
doShowMoreNotifications();
|
||||||
|
lockNotificationUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -190,12 +193,13 @@ public class NotificationsPanel extends Composite {
|
||||||
* called when a user scroll down the page to the bottom
|
* called when a user scroll down the page to the bottom
|
||||||
*/
|
*/
|
||||||
private void doShowMoreNotifications() {
|
private void doShowMoreNotifications() {
|
||||||
|
GWT.log("doShowMoreNotifications()");
|
||||||
showMoreNotificationsPanel.remove(0);
|
showMoreNotificationsPanel.remove(0);
|
||||||
loadingImage.getElement().getStyle().setMargin(10, Unit.PX);
|
loadingImage.getElement().getStyle().setMargin(10, Unit.PX);
|
||||||
showMoreNotificationsPanel.add(loadingImage);
|
showMoreNotificationsPanel.add(loadingImage);
|
||||||
int from = (fromStartingPoint == 0) ? NotificationConstants.NOTIFICATION_NUMBER+1 : fromStartingPoint;
|
int from = (fromStartingPoint == 0) ? NotificationConstants.NOTIFICATION_NUMBER+1 : fromStartingPoint;
|
||||||
fromStartingPoint = from;
|
fromStartingPoint = from;
|
||||||
final int quantity = 20;
|
final int quantity = 10;
|
||||||
GWT.log("StartingPoint = " + from);
|
GWT.log("StartingPoint = " + from);
|
||||||
|
|
||||||
notificationService.getUserNotificationsByRange(from, quantity, new AsyncCallback<HashMap<Date,ArrayList<Notification>>>() {
|
notificationService.getUserNotificationsByRange(from, quantity, new AsyncCallback<HashMap<Date,ArrayList<Notification>>>() {
|
||||||
|
@ -220,9 +224,11 @@ public class NotificationsPanel extends Composite {
|
||||||
GWT.log("Show MORE ");
|
GWT.log("Show MORE ");
|
||||||
showMoreNotificationsPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
|
showMoreNotificationsPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
|
||||||
showMoreWidget = new ShowMoreNotifications();
|
showMoreWidget = new ShowMoreNotifications();
|
||||||
|
showMoreNotificationsPanel.clear();
|
||||||
showMoreNotificationsPanel.add(showMoreWidget);
|
showMoreNotificationsPanel.add(showMoreWidget);
|
||||||
mainPanel.add(showMoreNotificationsPanel);
|
mainPanel.add(showMoreNotificationsPanel);
|
||||||
}
|
}
|
||||||
|
lockNotificationUpdate = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -54,7 +54,7 @@ a.link:hover {
|
||||||
.new-notifications-show {
|
.new-notifications-show {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
background: #D6E2FC;
|
background: #D6E2FC;
|
||||||
height: 18px;
|
height: 38px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue