|
13 | 13 | import android.net.Uri; |
14 | 14 | import android.os.Bundle; |
15 | 15 | import android.provider.OpenableColumns; |
| 16 | +import android.support.annotation.NonNull; |
16 | 17 | import android.support.annotation.Nullable; |
17 | 18 | import android.support.design.widget.Snackbar; |
18 | 19 | import android.support.design.widget.TextInputLayout; |
@@ -168,7 +169,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { |
168 | 169 | } |
169 | 170 |
|
170 | 171 | @Override |
171 | | - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
| 172 | + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
172 | 173 | return inflater.inflate(R.layout.fragment_create_message, container, false); |
173 | 174 | } |
174 | 175 |
|
@@ -333,8 +334,8 @@ public Loader<LoaderResult> onCreateLoader(int id, Bundle args) { |
333 | 334 | pgpContacts.clear(); |
334 | 335 | progressBarCheckContactsDetails.setVisibility(View.VISIBLE); |
335 | 336 | isUpdatedInfoAboutContactCompleted = false; |
336 | | - return new UpdateInfoAboutPgpContactsAsyncTaskLoader(getContext(), |
337 | | - editTextRecipients.getChipAndTokenValues()); |
| 337 | + List<String> emails = selectOnlyValidEmails(editTextRecipients.getChipAndTokenValues()); |
| 338 | + return new UpdateInfoAboutPgpContactsAsyncTaskLoader(getContext(), emails); |
338 | 339 |
|
339 | 340 | case R.id.loader_id_load_email_aliases: |
340 | 341 | return new LoadGmailAliasesLoader(getContext(), activeAccountDao); |
@@ -498,6 +499,22 @@ public boolean isMessageSendingNow() { |
498 | 499 | return isMessageSendingNow; |
499 | 500 | } |
500 | 501 |
|
| 502 | + /** |
| 503 | + * Remove not valid emails from the recipients list. |
| 504 | + * |
| 505 | + * @param emails The input list of recipients. |
| 506 | + * @return The list of valid emails. |
| 507 | + */ |
| 508 | + private List<String> selectOnlyValidEmails(List<String> emails) { |
| 509 | + List<String> validEmails = new ArrayList<>(); |
| 510 | + for (String email : emails) { |
| 511 | + if (js.str_is_email_valid(email)) { |
| 512 | + validEmails.add(email); |
| 513 | + } |
| 514 | + } |
| 515 | + return validEmails; |
| 516 | + } |
| 517 | + |
501 | 518 | /** |
502 | 519 | * Generate an outgoing message info from entered information by user. |
503 | 520 | * |
|
0 commit comments