use of com.google.web.bindery.event.shared.binder.EventHandler in project playshogi by Tellmarch.
the class ViewKifuActivity method onPositionChangedEvent.
@EventHandler
public void onPositionChangedEvent(final PositionChangedEvent event) {
GWT.log("ViewKifuActivity handling PositionChangedEvent");
// TODO: do all this only if we are in mainline
ShogiPosition position = event.getPosition();
int moveCount = position.getMoveCount();
if (!isPreviewOnly()) {
// Update URL with the new move count
History.replaceItem("ViewKifu:" + new ViewKifuPlace.Tokenizer().getToken(new ViewKifuPlace(kifuId, moveCount)), false);
}
if (analysisResult != null && analysisResult.getEvaluationDetails().length > moveCount) {
PositionEvaluationDetails detail = analysisResult.getEvaluationDetails()[moveCount];
Scheduler.get().scheduleDeferred(() -> eventBus.fireEvent(new PositionEvaluationEvent(detail)));
}
String gameSetId = "1";
kifuService.getPositionDetails(SfenConverter.toSFEN(position), gameSetId, new AsyncCallback<PositionDetails>() {
@Override
public void onSuccess(final PositionDetails result) {
GWT.log("VIEW KIFU - GOT POSITION DETAILS ");
eventBus.fireEvent(new PositionStatisticsEvent(result, position, gameSetId));
}
@Override
public void onFailure(final Throwable caught) {
GWT.log("VIEW KIFU - ERROR GETTING POSITION STATS");
}
});
}
use of com.google.web.bindery.event.shared.binder.EventHandler in project playshogi by Tellmarch.
the class ViewKifuActivity method onRequestKifuEvaluationEvent.
@EventHandler
public void onRequestKifuEvaluationEvent(final RequestKifuEvaluationEvent event) {
GWT.log("View Kifu Activity Handling RequestKifuEvaluationEvent");
String usf = UsfFormat.INSTANCE.write(viewKifuView.getNavigationController().getGameNavigation().getGameTree());
kifuService.requestKifuAnalysis(sessionInformation.getSessionId(), usf, new AsyncCallback<AnalysisRequestStatus>() {
@Override
public void onFailure(Throwable throwable) {
GWT.log("ViewKifu - error requesting kifu evaluation");
}
@Override
public void onSuccess(AnalysisRequestStatus result) {
GWT.log("ViewKifu - kifu evaluation result: " + result);
if (result.isDenied()) {
eventBus.fireEvent(new KifuEvaluationEvent(new AnalysisRequestResult(result), kifuId));
} else if (result.needToWait()) {
Timer timer = new Timer() {
@Override
public void run() {
queryKifuAnalysisResults(usf, this);
}
};
timer.scheduleRepeating(1000);
} else {
queryKifuAnalysisResults(usf, null);
}
}
});
}
use of com.google.web.bindery.event.shared.binder.EventHandler in project playshogi by Tellmarch.
the class ViewKifuActivity method onMoveSelectedEvent.
@EventHandler
public void onMoveSelectedEvent(final MoveSelectedEvent event) {
GWT.log("ViewKifuActivity handling MoveSelectedEvent");
eventBus.fireEvent(new GameTreeChangedEvent(gameRecord.getGameTree(), event.getMoveNumber()));
}
use of com.google.web.bindery.event.shared.binder.EventHandler in project playshogi by Tellmarch.
the class ViewLessonActivity method onVisitedProgress.
@EventHandler
public void onVisitedProgress(final VisitedProgressEvent event) {
GWT.log("ViewLessonActivity: Handling VisitedProgressEvent");
if (sessionInformation.isLoggedIn()) {
boolean complete = event.getTotal() == event.getVisited();
int newPercentage = 100 * event.getVisited() / event.getTotal();
if ((percentage != 100 && newPercentage == 100) || newPercentage > percentage + 10) {
percentage = newPercentage;
userService.saveLessonProgress(sessionInformation.getSessionId(), place.getLessonId(), duration.elapsedMillis(), complete, percentage, null, new FireAndForgetCallback("saveLessonProgress"));
}
}
}
use of com.google.web.bindery.event.shared.binder.EventHandler in project playshogi by Tellmarch.
the class ViewLessonActivity method onMarkLessonComplete.
@EventHandler
public void onMarkLessonComplete(final MarkLessonCompleteEvent event) {
GWT.log("ViewLessonActivity: Handling MarkLessonCompleteEvent");
if (sessionInformation.isLoggedIn()) {
percentage = 100;
userService.saveLessonProgress(sessionInformation.getSessionId(), place.getLessonId(), duration.elapsedMillis(), true, percentage, null, new FireAndForgetCallback("saveLessonProgress"));
Notification.createSuccess("Lesson was marked as complete").show();
}
}
Aggregations