mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 05:09:53 +01:00
[android] Add assertions to TextAttachmentController
This commit is contained in:
@@ -94,6 +94,7 @@ public class TextAttachmentController extends TextSendController
|
|||||||
@Override
|
@Override
|
||||||
public void onSendEvent() {
|
public void onSendEvent() {
|
||||||
if (canSend()) {
|
if (canSend()) {
|
||||||
|
if (loadingUris) throw new AssertionError();
|
||||||
listener.onSendClick(textInput.getText(),
|
listener.onSendClick(textInput.getText(),
|
||||||
attachmentManager.getAttachmentHeaders());
|
attachmentManager.getAttachmentHeaders());
|
||||||
reset();
|
reset();
|
||||||
@@ -139,6 +140,7 @@ public class TextAttachmentController extends TextSendController
|
|||||||
|
|
||||||
public void onImageReceived(@Nullable Intent resultData) {
|
public void onImageReceived(@Nullable Intent resultData) {
|
||||||
if (resultData == null) return;
|
if (resultData == null) return;
|
||||||
|
if (loadingUris) throw new AssertionError();
|
||||||
if (resultData.getData() != null) {
|
if (resultData.getData() != null) {
|
||||||
imageUris = new ArrayList<>(1);
|
imageUris = new ArrayList<>(1);
|
||||||
imageUris.add(resultData.getData());
|
imageUris.add(resultData.getData());
|
||||||
@@ -155,6 +157,7 @@ public class TextAttachmentController extends TextSendController
|
|||||||
|
|
||||||
private void onNewUris() {
|
private void onNewUris() {
|
||||||
if (imageUris.isEmpty()) return;
|
if (imageUris.isEmpty()) return;
|
||||||
|
if (loadingUris || urisLoaded != 0) throw new AssertionError();
|
||||||
loadingUris = true;
|
loadingUris = true;
|
||||||
updateViewState();
|
updateViewState();
|
||||||
textInput.setHint(R.string.image_caption_hint);
|
textInput.setHint(R.string.image_caption_hint);
|
||||||
@@ -169,6 +172,7 @@ public class TextAttachmentController extends TextSendController
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onAttachmentResultReceived(AttachmentResult result) {
|
private void onAttachmentResultReceived(AttachmentResult result) {
|
||||||
|
if (!loadingUris) return; // if this is false, the user cancelled
|
||||||
if (result.isError() || result.getUri() == null) {
|
if (result.isError() || result.getUri() == null) {
|
||||||
onError(result.getErrorMsg());
|
onError(result.getErrorMsg());
|
||||||
} else {
|
} else {
|
||||||
@@ -227,6 +231,7 @@ public class TextAttachmentController extends TextSendController
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkAllUrisLoaded() {
|
private void checkAllUrisLoaded() {
|
||||||
|
if (!loadingUris) throw new AssertionError();
|
||||||
if (urisLoaded == imageUris.size()) {
|
if (urisLoaded == imageUris.size()) {
|
||||||
loadingUris = false;
|
loadingUris = false;
|
||||||
// all images were turned into attachments
|
// all images were turned into attachments
|
||||||
|
|||||||
Reference in New Issue
Block a user