public void put(final String key, DMRResponse response) { values.put(key, response); Scheduler.get().scheduleFixedPeriod( new Scheduler.RepeatingCommand() { @Override public boolean execute() { values.remove(key); return false; } }, expiryTimeMs ); }
public void put(final String key, DMRResponse response) { values.put(key, response); Scheduler.get().scheduleFixedPeriod( new Scheduler.RepeatingCommand() { @Override public boolean execute() { values.remove(key); return false; } }, expiryTimeMs ); }
/** * Check for updates to the application cache every 30 minutes */ private void scheduleUpdateChecker() { Scheduler.get().scheduleFixedPeriod(new Scheduler.RepeatingCommand() { @Override public boolean execute() { if (!updating) { updateCache(); } return true; } }, updateCheckInterval); }
private void recalculateTabCount() { final int[] counter = new int[]{0}; Scheduler.get().scheduleFixedPeriod(new Scheduler.RepeatingCommand() { @Override public boolean execute() { counter[0]++; NodeList<Element> buttons = getElement().getElementsByTagName("li"); if (buttons.getLength() > 0) { Element firstButton = buttons.getItem(0); Element lastButton = buttons.getItem(buttons.getLength() - 1); if (firstButton.getAbsoluteTop() != lastButton.getAbsoluteTop()) { tabCount--; render(); } return false; } if (counter[0] > 10) { // safe exit return false; } return true; } }, 500); }
public ObservableCache() { if(GWT.isClient()) { Scheduler.get().scheduleFixedPeriod(this::sweepCache, CLEANUP_DELAY_MS); } }
@Override public int setPeriodic(int delayMs, final Handler<Void> handler) { final int id = timerId++; RepeatingCommand cmd = new RepeatingCommand() { @Override public boolean execute() { if (timers.has("" + id)) { handler.handle(null); return true; } return false; } }; timers.set("" + id, cmd); Scheduler.get().scheduleFixedPeriod(cmd, delayMs); return id; }
private void retry(final CommandRequest request, final RetryCountDown retryCountDown) { try { long waitPeriod = retryCountDown.countDownAndGetWaitPeriod(); Log.debug("Retry will run in " + waitPeriod + "ms."); scheduler.scheduleFixedPeriod(new RepeatingCommand() { @Override public boolean execute() { executeCommand(request, retryCountDown); return false; } }, (int) waitPeriod); } catch (Exception e) { Log.error(e.getMessage(), e); executingCommands.remove(request); request.onFailure(e); } } }
@Inject public LastSyncStatus(EventBus eventBus) { this.eventBus = eventBus; setStyleAttribute("cursor", "pointer"); eventBus.addListener(SyncCompleteEvent.TYPE, new Listener<SyncCompleteEvent>() { @Override public void handleEvent(SyncCompleteEvent event) { lastSyncTime = event.getTime(); setBox(true); updateLastSyncLabel(); } }); Scheduler.get().scheduleFixedPeriod(new RepeatingCommand() { @Override public boolean execute() { updateLastSyncLabel(); return true; } }, UPDATE_DELAY); sinkEvents(Event.ONCLICK); }
private void pollForStatusOnAndroid() { if (BrowserInfo.get().isAndroid()) { Scheduler.get().scheduleFixedPeriod( new Scheduler.RepeatingCommand() { @Override public boolean execute() { if (updating) { // The normal listeners are working correctly return false; } switch (getStatus()) { case IDLE: hideProgress(); return false; case UPDATEREADY: requestUpdate(false); return false; default: return true; } } }, 500); } }
private void refreshWithNewlyParsedRows() { eventBus.fireEvent(new PageChangedEvent(false, I18N.CONSTANTS.parsingRows())); Scheduler.get().scheduleFixedPeriod(new Scheduler.RepeatingCommand() { @Override public boolean execute() { SourceTable sourceTable = model.getSource(); if (!sourceTable.parsedAllRows()) { sourceTable.parseNextRows(50); ColumnMappingGrid.this.setRowData(model.getSource().getRows()); ColumnMappingGrid.this.getRowElement(ColumnMappingGrid.this.getRowCount() - 1).scrollIntoView(); } else { ColumnMappingGrid.this.scrollColumnIntoView(0); eventBus.fireEvent(new PageChangedEvent(true, "")); return false; } return true; } }, 1); } }
/** * Create message stack. * * @param resources core resources */ @Inject public NotificationPopupStack(final Resources resources) { notificationContainer.ensureDebugId(NOTIFICATION_CONTAINER_DBG_ID); notificationContainer.setStyleName(resources.notificationCss().notificationPopupPlaceholder()); RootPanel.get().add(notificationContainer); Scheduler.get() .scheduleFixedPeriod( new Scheduler.RepeatingCommand() { /** {@inheritDoc} */ @Override public boolean execute() { while (notificationContainer.getWidgetCount() < POPUP_COUNT && !stack.isEmpty()) { notificationContainer.add( new NotificationPopup(stack.pop(), resources, NotificationPopupStack.this)); } return true; } }, 1000); }
.scheduleFixedPeriod( new Scheduler.RepeatingCommand() { @Override
public void goOffline(ActivationEvent event) { online = false; getConnection().setApplicationRunning(false); if (!getOfflineApp().isActive()) { getOfflineApp().activate(event); if (!isNetworkOnline()) { Scheduler.get() .scheduleFixedPeriod(new CheckForNetwork(), 1000); } } }
/** {@inheritDoc} */ @Override public void scrollBottom() { /** scroll bottom immediately if view is visible */ if (scrollPanel.getElement().getOffsetParent() != null) { scrollPanel.getElement().setScrollTop(scrollPanel.getElement().getScrollHeight()); return; } /** otherwise, check the visibility periodically and scroll the view when it's visible */ if (!scrollBottomRequired) { scrollBottomRequired = true; Scheduler.get() .scheduleFixedPeriod( new Scheduler.RepeatingCommand() { @Override public boolean execute() { if (scrollPanel.getElement().getOffsetParent() != null) { scrollPanel .getElement() .setScrollTop(scrollPanel.getElement().getScrollHeight()); scrollBottomRequired = false; return false; } return true; } }, 1000); } }