[android] migrate added conversation header to new LiveEvent

This commit is contained in:
Torsten Grote
2019-05-15 16:45:53 -03:00
parent 67b7517f2b
commit 4ee4905e06
2 changed files with 5 additions and 11 deletions

View File

@@ -243,7 +243,7 @@ public class ConversationActivity extends BriarActivity
requireNonNull(deleted); requireNonNull(deleted);
if (deleted) finish(); if (deleted) finish();
}); });
viewModel.getAddedPrivateMessage().observe(this, viewModel.getAddedPrivateMessage().observeEvent(this,
this::onAddedPrivateMessage); this::onAddedPrivateMessage);
setTransitionName(toolbarAvatar, getAvatarTransitionName(contactId)); setTransitionName(toolbarAvatar, getAvatarTransitionName(contactId));
@@ -678,7 +678,6 @@ public class ConversationActivity extends BriarActivity
private void onAddedPrivateMessage(@Nullable PrivateMessageHeader h) { private void onAddedPrivateMessage(@Nullable PrivateMessageHeader h) {
if (h == null) return; if (h == null) return;
addConversationItem(h.accept(visitor)); addConversationItem(h.accept(visitor));
viewModel.onAddedPrivateMessageSeen();
} }
private void askToRemoveContact() { private void askToRemoveContact() {

View File

@@ -97,8 +97,8 @@ public class ConversationViewModel extends AndroidViewModel
new MutableLiveData<>(); new MutableLiveData<>();
private final MutableLiveData<Boolean> contactDeleted = private final MutableLiveData<Boolean> contactDeleted =
new MutableLiveData<>(); new MutableLiveData<>();
private final MutableLiveData<PrivateMessageHeader> addedHeader = private final MutableLiveEvent<PrivateMessageHeader> addedHeader =
new MutableLiveData<>(); new MutableLiveEvent<>();
@Inject @Inject
ConversationViewModel(Application application, ConversationViewModel(Application application,
@@ -301,18 +301,13 @@ public class ConversationViewModel extends AndroidViewModel
text != null, attachments); text != null, attachments);
attachmentCreator.onAttachmentsSent(m.getMessage().getId()); attachmentCreator.onAttachmentsSent(m.getMessage().getId());
// TODO add text to cache when available here // TODO add text to cache when available here
addedHeader.postValue(h); addedHeader.postEvent(h);
} catch (DbException e) { } catch (DbException e) {
logException(LOG, WARNING, e); logException(LOG, WARNING, e);
} }
}); });
} }
@UiThread
void onAddedPrivateMessageSeen() {
addedHeader.setValue(null);
}
AttachmentRetriever getAttachmentRetriever() { AttachmentRetriever getAttachmentRetriever() {
return attachmentRetriever; return attachmentRetriever;
} }
@@ -349,7 +344,7 @@ public class ConversationViewModel extends AndroidViewModel
return contactDeleted; return contactDeleted;
} }
LiveData<PrivateMessageHeader> getAddedPrivateMessage() { LiveEvent<PrivateMessageHeader> getAddedPrivateMessage() {
return addedHeader; return addedHeader;
} }