Skip to content

Commit

Permalink
chore: Dismiss RoleInviteFragment after invitation is sent (#1721)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShridharGoel authored and iamareebjamal committed Jun 15, 2019
1 parent 43f025b commit 63fce1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void onStart() {
roleInviteViewModel.getProgress().observe(this, this::showProgress);
roleInviteViewModel.getSuccess().observe(this, this::onSuccess);
roleInviteViewModel.getError().observe(this, this::showError);
roleInviteViewModel.getDismiss().observe(this, (dismiss) -> dismiss());
binding.setRoleInvite(roleInviteViewModel.getRoleInvite());
setUpSpinner();
}
Expand Down Expand Up @@ -96,4 +97,8 @@ public void onSuccess(String message) {
public void showProgress(boolean show) {
showView(binding.progressBar, show);
}

public void dismiss() {
getFragmentManager().popBackStack();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class RoleInviteViewModel extends ViewModel {
private final SingleEventLiveData<Boolean> progress = new SingleEventLiveData<>();
private final SingleEventLiveData<String> error = new SingleEventLiveData<>();
private final SingleEventLiveData<String> success = new SingleEventLiveData<>();
private final SingleEventLiveData<Void> dismiss = new SingleEventLiveData<>();

@Inject
public RoleInviteViewModel(RoleRepository roleRepository) {
Expand All @@ -47,6 +48,10 @@ public LiveData<String> getError() {
return error;
}

public LiveData<Void> getDismiss() {
return dismiss;
}

public void createRoleInvite(long roleId) {

long eventId = ContextManager.getSelectedEvent().getId();
Expand All @@ -63,6 +68,7 @@ public void createRoleInvite(long roleId) {
.doFinally(() -> progress.setValue(false))
.subscribe(sentRoleInvite -> {
success.setValue("Role Invite Sent");
dismiss.call();
}, throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
}

0 comments on commit 63fce1f

Please sign in to comment.