mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Remove PartialItem interface and the need for casting ConversationItems
This commit is contained in:
@@ -29,7 +29,6 @@ import org.briarproject.android.ActivityComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.api.AndroidNotificationManager;
|
||||
import org.briarproject.android.contact.ConversationAdapter.RequestListener;
|
||||
import org.briarproject.android.contact.ConversationItem.PartialItem;
|
||||
import org.briarproject.android.introduction.IntroductionActivity;
|
||||
import org.briarproject.android.view.BriarRecyclerView;
|
||||
import org.briarproject.android.view.TextInputView;
|
||||
@@ -413,7 +412,7 @@ public class ConversationActivity extends BriarActivity
|
||||
ConversationItem item = ConversationItem.from(h);
|
||||
String body = bodyCache.get(h.getId());
|
||||
if (body == null) loadMessageBody(h.getId());
|
||||
else ((PartialItem) item).setText(body);
|
||||
else item.setBody(body);
|
||||
items.add(item);
|
||||
}
|
||||
for (IntroductionMessage m : introductions) {
|
||||
@@ -474,7 +473,7 @@ public class ConversationActivity extends BriarActivity
|
||||
for (int i = 0; i < messages.size(); i++) {
|
||||
ConversationItem item = messages.valueAt(i);
|
||||
if (item.getId().equals(m)) {
|
||||
((PartialItem) item).setText(body);
|
||||
item.setBody(body);
|
||||
adapter.notifyItemChanged(messages.keyAt(i));
|
||||
list.scrollToPosition(adapter.getItemCount() - 1);
|
||||
return;
|
||||
@@ -681,7 +680,7 @@ public class ConversationActivity extends BriarActivity
|
||||
groupId, m.getMessage().getTimestamp(),
|
||||
m.getContentType(), true, false, false, false);
|
||||
ConversationItem item = ConversationItem.from(h);
|
||||
((PartialItem) item).setText(body);
|
||||
item.setBody(body);
|
||||
bodyCache.put(id, body);
|
||||
addConversationItem(item);
|
||||
} catch (DbException e) {
|
||||
|
||||
@@ -33,16 +33,16 @@ import static org.briarproject.android.contact.ConversationRequestItem.RequestTy
|
||||
@NotNullByDefault
|
||||
abstract class ConversationItem {
|
||||
|
||||
protected @Nullable String text;
|
||||
protected @Nullable String body;
|
||||
final private MessageId id;
|
||||
final private GroupId groupId;
|
||||
final private long time;
|
||||
|
||||
ConversationItem(MessageId id, GroupId groupId,
|
||||
@Nullable String text, long time) {
|
||||
@Nullable String body, long time) {
|
||||
this.id = id;
|
||||
this.groupId = groupId;
|
||||
this.text = text;
|
||||
this.body = body;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@@ -54,9 +54,13 @@ abstract class ConversationItem {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
void setBody(String body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getText() {
|
||||
return text;
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
long getTime() {
|
||||
@@ -279,13 +283,4 @@ abstract class ConversationItem {
|
||||
}
|
||||
}
|
||||
|
||||
interface PartialItem {
|
||||
|
||||
@Nullable
|
||||
String getText();
|
||||
|
||||
void setText(String text);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ class ConversationItemViewHolder extends ViewHolder {
|
||||
|
||||
@CallSuper
|
||||
void bind(ConversationItem item) {
|
||||
if (item.getText() == null) {
|
||||
if (item.getBody() == null) {
|
||||
text.setText("\u2026");
|
||||
} else {
|
||||
text.setText(StringUtils.trim(item.getText()));
|
||||
text.setText(StringUtils.trim(item.getBody()));
|
||||
}
|
||||
|
||||
long timestamp = item.getTime();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.android.contact;
|
||||
|
||||
import org.briarproject.android.contact.ConversationItem.PartialItem;
|
||||
import org.briarproject.api.messaging.PrivateMessageHeader;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
|
||||
@@ -8,15 +7,10 @@ import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
@NotThreadSafe
|
||||
@NotNullByDefault
|
||||
class ConversationMessageInItem extends ConversationInItem
|
||||
implements PartialItem {
|
||||
class ConversationMessageInItem extends ConversationInItem {
|
||||
|
||||
ConversationMessageInItem(PrivateMessageHeader h) {
|
||||
super(h.getId(), h.getGroupId(), null, h.getTimestamp(), h.isRead());
|
||||
}
|
||||
|
||||
public void setText(String body) {
|
||||
text = body;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.android.contact;
|
||||
|
||||
import org.briarproject.android.contact.ConversationItem.PartialItem;
|
||||
import org.briarproject.api.messaging.PrivateMessageHeader;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
|
||||
@@ -8,16 +7,11 @@ import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
@NotThreadSafe
|
||||
@NotNullByDefault
|
||||
class ConversationMessageOutItem extends ConversationOutItem
|
||||
implements PartialItem {
|
||||
class ConversationMessageOutItem extends ConversationOutItem {
|
||||
|
||||
ConversationMessageOutItem(PrivateMessageHeader h) {
|
||||
super(h.getId(), h.getGroupId(), null, h.getTimestamp(), h.isSent(),
|
||||
h.isSeen());
|
||||
}
|
||||
|
||||
public void setText(String body) {
|
||||
text = body;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user