mirror of
https://github.com/maxkratz/lectureStudio.git
synced 2024-10-14 01:33:49 +00:00
presenter-api: fixed menu state for messenger #379
This commit is contained in:
parent
f7d598acbd
commit
4ec0db7d63
3 changed files with 34 additions and 8 deletions
|
@ -45,9 +45,12 @@ public class StartCourseFeaturePresenter extends Presenter<StartCourseFeatureVie
|
|||
|
||||
private Course course;
|
||||
|
||||
/** The action that is executed when the saving process has been aborted. */
|
||||
/** The action that is executed when the user clicked the start button. */
|
||||
private Action startAction;
|
||||
|
||||
/** The action that is executed when the process has been aborted. */
|
||||
private Action abortAction;
|
||||
|
||||
|
||||
@Inject
|
||||
StartCourseFeaturePresenter(ApplicationContext context,
|
||||
|
@ -105,6 +108,10 @@ public class StartCourseFeaturePresenter extends Presenter<StartCourseFeatureVie
|
|||
|
||||
PresenterContext presenterContext = (PresenterContext) context;
|
||||
presenterContext.setStreamStarted(false);
|
||||
|
||||
if (nonNull(abortAction)) {
|
||||
abortAction.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,6 +127,10 @@ public class StartCourseFeaturePresenter extends Presenter<StartCourseFeatureVie
|
|||
startAction = action;
|
||||
}
|
||||
|
||||
public void setOnAbort(Action action) {
|
||||
abortAction = action;
|
||||
}
|
||||
|
||||
private void onStart() {
|
||||
dispose();
|
||||
|
||||
|
|
|
@ -27,19 +27,27 @@ public class StartCourseFeatureCommand extends ShowPresenterCommand<StartCourseF
|
|||
|
||||
private final Action startAction;
|
||||
|
||||
private final Action abortAction;
|
||||
|
||||
private final Course course;
|
||||
|
||||
|
||||
public StartCourseFeatureCommand(Course course, Action startAction) {
|
||||
this(course, startAction, null);
|
||||
}
|
||||
|
||||
public StartCourseFeatureCommand(Course course, Action startAction, Action abortAction) {
|
||||
super(StartCourseFeaturePresenter.class);
|
||||
|
||||
this.course = course;
|
||||
this.startAction = startAction;
|
||||
this.abortAction = abortAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(StartCourseFeaturePresenter presenter) {
|
||||
presenter.setCourse(course);
|
||||
presenter.setOnStart(startAction);
|
||||
presenter.setOnAbort(abortAction);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,9 +127,10 @@ public class StreamService {
|
|||
context.getCourse() :
|
||||
null;
|
||||
|
||||
eventBus.post(new StartCourseFeatureCommand(course, () -> {
|
||||
startQuizInternal(quiz);
|
||||
}));
|
||||
eventBus.post(new StartCourseFeatureCommand(course,
|
||||
() -> {
|
||||
startQuizInternal(quiz);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,7 +271,7 @@ public class StreamService {
|
|||
}
|
||||
|
||||
private void startMessenger() {
|
||||
if (!webRtcStreamService.stopped()) {
|
||||
if (webRtcStreamService.started()) {
|
||||
startMessengerInternal();
|
||||
}
|
||||
else {
|
||||
|
@ -278,9 +279,15 @@ public class StreamService {
|
|||
context.getCourse() :
|
||||
null;
|
||||
|
||||
eventBus.post(new StartCourseFeatureCommand(course, () -> {
|
||||
startMessengerInternal();
|
||||
}));
|
||||
eventBus.post(new StartCourseFeatureCommand(course,
|
||||
() -> {
|
||||
// On start.
|
||||
startMessengerInternal();
|
||||
},
|
||||
() -> {
|
||||
// On abort.
|
||||
context.setMessengerStarted(false);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue