Commit a37b6d81 authored by akwizgran's avatar akwizgran

Merge branch '1242-save-snackbar-fix' into 'master'

[android] Clarify the meaning of image save state

See merge request briar/briar!1017
parents 1e2c17b1 8b9f89ea
Pipeline #2911 passed with stage
in 12 minutes and 42 seconds
...@@ -50,9 +50,12 @@ public class ImageViewModel extends AndroidViewModel { ...@@ -50,9 +50,12 @@ public class ImageViewModel extends AndroidViewModel {
@IoExecutor @IoExecutor
private final Executor ioExecutor; private final Executor ioExecutor;
/**
* true means there was an error saving the image, false if image was saved.
*/
private final MutableLiveData<Boolean> saveState = new MutableLiveData<>();
private final MutableLiveData<Boolean> imageClicked = private final MutableLiveData<Boolean> imageClicked =
new MutableLiveData<>(); new MutableLiveData<>();
private final MutableLiveData<Boolean> saveState = new MutableLiveData<>();
private int toolbarTop, toolbarBottom; private int toolbarTop, toolbarBottom;
@Inject @Inject
...@@ -106,8 +109,9 @@ public class ImageViewModel extends AndroidViewModel { ...@@ -106,8 +109,9 @@ public class ImageViewModel extends AndroidViewModel {
} }
/** /**
* A LiveData that is true if the image was saved, * A LiveData that is true if there was an error
* false if there was an error and null otherwise. * and false if the image was saved.
* It can be null otherwise, if no image was saved recently.
* *
* Call {@link #onSaveStateSeen()} after consuming an update. * Call {@link #onSaveStateSeen()} after consuming an update.
*/ */
...@@ -126,7 +130,7 @@ public class ImageViewModel extends AndroidViewModel { ...@@ -126,7 +130,7 @@ public class ImageViewModel extends AndroidViewModel {
@UiThread @UiThread
void saveImage(AttachmentItem attachment, @Nullable Uri uri) { void saveImage(AttachmentItem attachment, @Nullable Uri uri) {
if (uri == null) { if (uri == null) {
saveState.setValue(false); saveState.setValue(true);
} else { } else {
saveImage(attachment, () -> getOutputStream(uri), null); saveImage(attachment, () -> getOutputStream(uri), null);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment