mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 02:39:05 +01:00
[android] attach some smaller image attachment issues
This commit is contained in:
@@ -135,10 +135,6 @@ public class AttachmentItem implements Parcelable {
|
||||
return toHexString(instanceId);
|
||||
}
|
||||
|
||||
boolean hasSize() {
|
||||
return width != 0 && height != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
@@ -156,6 +152,10 @@ public class AttachmentItem implements Parcelable {
|
||||
dest.writeString(state.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used to identity if two items are the same,
|
||||
* irrespective of their state or size.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(@Nullable Object o) {
|
||||
return o instanceof AttachmentItem &&
|
||||
@@ -164,4 +164,8 @@ public class AttachmentItem implements Parcelable {
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return header.getMessageId().hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,13 @@ public interface AttachmentRetriever {
|
||||
* Loads an {@link AttachmentItem}
|
||||
* that arrived via an {@link AttachmentReceivedEvent}
|
||||
* and notifies the associated {@link LiveData}.
|
||||
*
|
||||
* Note that you need to call {@link #getAttachmentItems(PrivateMessageHeader)}
|
||||
* first to get the LiveData.
|
||||
*
|
||||
* It is possible that no LiveData is available,
|
||||
* because the message of the AttachmentItem did not arrive, yet.
|
||||
* In this case, the load wil be deferred until the message arrives.
|
||||
*/
|
||||
@DatabaseExecutor
|
||||
void loadAttachmentItem(MessageId attachmentId);
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package org.briarproject.briar.android.attachment;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.messaging.AttachmentHeader;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
class UnavailableItem {
|
||||
|
||||
private final MessageId conversationMessageId;
|
||||
private final AttachmentHeader header;
|
||||
private final boolean needsSize;
|
||||
|
||||
UnavailableItem(MessageId conversationMessageId,
|
||||
AttachmentHeader header, boolean needsSize) {
|
||||
this.conversationMessageId = conversationMessageId;
|
||||
this.header = header;
|
||||
this.needsSize = needsSize;
|
||||
}
|
||||
|
||||
MessageId getConversationMessageId() {
|
||||
return conversationMessageId;
|
||||
}
|
||||
|
||||
AttachmentHeader getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
boolean needsSize() {
|
||||
return needsSize;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -640,16 +640,14 @@ public class ConversationActivity extends BriarActivity
|
||||
&& adapter.isScrolledToBottom(layoutManager);
|
||||
}
|
||||
|
||||
@UiThread
|
||||
private void updateMessageAttachment(MessageId m, AttachmentItem item) {
|
||||
runOnUiThreadUnlessDestroyed(() -> {
|
||||
Pair<Integer, ConversationMessageItem> pair =
|
||||
adapter.getMessageItem(m);
|
||||
if (pair != null && pair.getSecond().updateAttachments(item)) {
|
||||
boolean scroll = shouldScrollWhenUpdatingMessage();
|
||||
adapter.notifyItemChanged(pair.getFirst());
|
||||
if (scroll) scrollToBottom();
|
||||
}
|
||||
});
|
||||
Pair<Integer, ConversationMessageItem> pair = adapter.getMessageItem(m);
|
||||
if (pair != null && pair.getSecond().updateAttachments(item)) {
|
||||
boolean scroll = shouldScrollWhenUpdatingMessage();
|
||||
adapter.notifyItemChanged(pair.getFirst());
|
||||
if (scroll) scrollToBottom();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -59,7 +59,7 @@ class ImageAdapter extends Adapter<ImageViewHolder> {
|
||||
// get item
|
||||
requireNonNull(conversationItem);
|
||||
AttachmentItem item = items.get(position);
|
||||
// set onClick listener, if not missing or error
|
||||
// set onClick listener
|
||||
imageViewHolder.itemView.setOnClickListener(v ->
|
||||
listener.onAttachmentClicked(v, conversationItem, item)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user