Skip to content

Commit

Permalink
When there are no recipients left on group create screen toast and re…
Browse files Browse the repository at this point in the history
…turn to list.
  • Loading branch information
alan-signal committed Jun 10, 2020
1 parent 44fe43c commit c0c2fc0
Showing 1 changed file with 8 additions and 4 deletions.
Expand Up @@ -8,10 +8,7 @@
import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
import android.os.Bundle;
import android.view.ActionMode;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
Expand Down Expand Up @@ -116,7 +113,13 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
name.addTextChangedListener(new AfterTextChanged(editable -> viewModel.setName(editable.toString())));
toolbar.setNavigationOnClickListener(unused -> callback.onNavigationButtonPressed());
create.setOnClickListener(v -> handleCreateClicked());
viewModel.getMembers().observe(getViewLifecycleOwner(), members::setMembers);
viewModel.getMembers().observe(getViewLifecycleOwner(), recipients -> {
members.setMembers(recipients);
if (recipients.isEmpty()) {
toast(R.string.AddGroupDetailsFragment__groups_require_at_least_two_members);
callback.onNavigationButtonPressed();
}
});
viewModel.getCanSubmitForm().observe(getViewLifecycleOwner(), isFormValid -> setCreateEnabled(isFormValid, true));
viewModel.getIsMms().observe(getViewLifecycleOwner(), isMms -> {
mmsWarning.setVisibility(isMms ? View.VISIBLE : View.GONE);
Expand Down Expand Up @@ -226,6 +229,7 @@ private void handleGroupCreateResultError(@NonNull GroupCreateResult.Error error
break;
case ERROR_INVALID_MEMBER_COUNT:
toast(R.string.AddGroupDetailsFragment__groups_require_at_least_two_members);
callback.onNavigationButtonPressed();
break;
default:
throw new IllegalStateException("Unexpected error: " + error.getErrorType().name());
Expand Down

0 comments on commit c0c2fc0

Please sign in to comment.