@Override public Type<LockInteractionHandler> getAssociatedType() { return getType(); }
/** * Fires a {@link LockInteractionEvent} * into a source that has access to an {@link com.google.web.bindery.event.shared.EventBus} * specifying whether interaction should be locked or unlocked. * * @param source The source that fires this event ({@link HasHandlers}). * @param lock {@code true} to lock interaction, {@code false} to unlock it. */ public static void fire(HasHandlers source, boolean lock) { source.fireEvent(new LockInteractionEvent(lock)); }
private void lock() { if (!locked) { locked = true; LockInteractionEvent.fire(this, true); } }
@Override public void onLockInteraction(LockInteractionEvent lockInteractionEvent) { if (lockInteractionEvent.shouldLock()) { getView().lockScreen(); } else { getView().unlockScreen(); } }
@Override public void onLockInteraction(LockInteractionEvent event) { // Allow progress indicator to be hidden regardless of the current (non-empty) place boolean emptyPlace = placeManager.getCurrentPlaceRequest().getNameToken() == null; if (!emptyPlace && !event.shouldLock()) { // Use deferred command because some other initialization might happen // right after place transition; therefore we want to hide the loading // indicator only after the browser event loop returns Scheduler.get().scheduleDeferred(() -> hideLoadingIndicator()); } // Set data attribute on body element to indicate the status of the application BodyElement body = Document.get().getBody(); if (event.shouldLock()) { body.setAttribute(APP_STATUS_ATTRIBUTE, APP_STATUS_BUSY); } else { body.setAttribute(APP_STATUS_ATTRIBUTE, APP_STATUS_READY); } }
@Inject public LockInteractionManager(EventBus eventBus, PlaceManager placeManager) { this.placeManager = placeManager; eventBus.addHandler(LockInteractionEvent.getType(), this); }
@Override public void unlock() { if (locked) { locked = false; LockInteractionEvent.fire(this, false); if (hasPendingNavigation()) { Command navigation = defferedNavigation; defferedNavigation = null; navigation.execute(); } } }
@Override protected void onBind() { super.onBind(); addRegisteredHandler(ResetPresentersEvent.getType(), this); addRegisteredHandler(RevealRootContentEvent.getType(), this); addRegisteredHandler(RevealRootLayoutContentEvent.getType(), this); addRegisteredHandler(RevealRootPopupContentEvent.getType(), this); addRegisteredHandler(LockInteractionEvent.getType(), this); } }