Skip to content

Commit

Permalink
removed unnecessary method GameBoardViewModel::updateUiState
Browse files Browse the repository at this point in the history
Signed-off-by: PeterNaggschga <rep.akhcsztan@gmail.com>
  • Loading branch information
PeterNaggschga committed Mar 26, 2024
1 parent 9148c28 commit 65d9b8f
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,17 @@ public MutableLiveData<MenuUiState> getMenuUiState() {
return menuUiState;
}

public Completable updateUi() {
return updateUiState();
}

@NonNull
private Completable updateUiState() {
public Completable updateUi() {
Completable result = Completable.complete();
for (RowType row : RowType.values()) {
result = result.andThen(updateUiState(row));
result = result.andThen(updateUi(row));
}
return result;
}

@NonNull
private Completable updateUiState(@NonNull RowType row) {
private Completable updateUi(@NonNull RowType row) {
return Completable.create(emitter -> {
MutableLiveData<RowUiState> rowState = getRowUiState(row);
// noinspection CheckResult, ResultOfMethodCallIgnored
Expand All @@ -123,13 +119,13 @@ private Completable updateUiState(@NonNull RowType row) {
@NonNull
public Single<Boolean> onWeatherViewPressed(@NonNull RowType row) {
return repository.switchWeather(row)
.andThen(updateUiState(row))
.andThen(updateUi(row))
.andThen(repository.isWeather(row));
}

public Single<Boolean> onHornViewPressed(@NonNull RowType row) {
return repository.switchHorn(row)
.andThen(updateUiState(row))
.andThen(updateUi(row))
.andThen(repository.isHorn(row));
}

Expand All @@ -147,16 +143,16 @@ public Single<Boolean> onFactionSwitchReset(@NonNull Context context) {
private Single<Boolean> reset(@NonNull Context context,
@IntRange(from = TRIGGER_BUTTON_CLICK, to = TRIGGER_FACTION_SWITCH) int trigger) {
return ResetDialogUseCase.reset(context, repository, trigger)
.flatMap(resetComplete -> updateUiState().andThen(Single.just(resetComplete)));
.flatMap(resetComplete -> updateUi().andThen(Single.just(resetComplete)));
}

public Completable onWeatherButtonPressed() {
return repository.clearWeather()
.andThen(updateUiState());
.andThen(updateUi());
}

public Single<Boolean> onBurnButtonPressed(@NonNull Context context) {
return BurnDialogUseCase.burn(context, repository)
.flatMap(burnComplete -> updateUiState().andThen(Single.just(burnComplete)));
.flatMap(burnComplete -> updateUi().andThen(Single.just(burnComplete)));
}
}

0 comments on commit 65d9b8f

Please sign in to comment.