Skip to content
Snippets Groups Projects
Commit 4af5dbb4 authored by akwizgran's avatar akwizgran
Browse files

Merge branch '562-npe-in-contactlistfragment' into 'master'

Fix NPE in ContactListFragment

Closes #562

See merge request !261
parents 7132c886 31cd6e89
No related branches found
No related tags found
No related merge requests found
...@@ -375,6 +375,7 @@ public class ContactListFragment extends BaseFragment implements EventListener { ...@@ -375,6 +375,7 @@ public class ContactListFragment extends BaseFragment implements EventListener {
} }
// This needs to be called from the DB thread // This needs to be called from the DB thread
// Do not call getActivty() here as it might return null
private Collection<ConversationItem> getMessages(ContactId id) private Collection<ConversationItem> getMessages(ContactId id)
throws DbException { throws DbException {
...@@ -406,13 +407,7 @@ public class ContactListFragment extends BaseFragment implements EventListener { ...@@ -406,13 +407,7 @@ public class ContactListFragment extends BaseFragment implements EventListener {
Collection<InvitationMessage> invitations = Collection<InvitationMessage> invitations =
forumSharingManager.getInvitationMessages(id); forumSharingManager.getInvitationMessages(id);
for (InvitationMessage i : invitations) { for (InvitationMessage i : invitations) {
if (i instanceof ForumInvitationRequest) { messages.add(ConversationItem.from(i));
ForumInvitationRequest r = (ForumInvitationRequest) i;
messages.add(ConversationItem.from(r));
} else if (i instanceof ForumInvitationResponse) {
ForumInvitationResponse r = (ForumInvitationResponse) i;
messages.add(ConversationItem.from(getActivity(), "", r));
}
} }
duration = System.currentTimeMillis() - now; duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO)) if (LOG.isLoggable(INFO))
......
...@@ -9,6 +9,7 @@ import org.briarproject.api.introduction.IntroductionMessage; ...@@ -9,6 +9,7 @@ import org.briarproject.api.introduction.IntroductionMessage;
import org.briarproject.api.introduction.IntroductionRequest; import org.briarproject.api.introduction.IntroductionRequest;
import org.briarproject.api.introduction.IntroductionResponse; import org.briarproject.api.introduction.IntroductionResponse;
import org.briarproject.api.messaging.PrivateMessageHeader; import org.briarproject.api.messaging.PrivateMessageHeader;
import org.briarproject.api.sharing.InvitationMessage;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
// This class is not thread-safe // This class is not thread-safe
...@@ -138,7 +139,7 @@ public abstract class ConversationItem { ...@@ -138,7 +139,7 @@ public abstract class ConversationItem {
/** /**
* This method should not be used to get user-facing objects, * This method should not be used to get user-facing objects,
* Its purpose is to provider data for the contact list. * Its purpose is only to provide data for the contact list.
*/ */
public static ConversationItem from(IntroductionMessage im) { public static ConversationItem from(IntroductionMessage im) {
if (im.isLocal()) if (im.isLocal())
...@@ -148,6 +149,18 @@ public abstract class ConversationItem { ...@@ -148,6 +149,18 @@ public abstract class ConversationItem {
im.getTimestamp(), im.isRead()); im.getTimestamp(), im.isRead());
} }
/**
* This method should not be used to get user-facing objects,
* Its purpose is only to provide data for the contact list.
*/
public static ConversationItem from(InvitationMessage im) {
if (im.isLocal())
return new ConversationNoticeOutItem(im.getId(), "",
im.getTimestamp(), false, false);
return new ConversationNoticeInItem(im.getId(), "",
im.getTimestamp(), im.isRead());
}
interface OutgoingItem { interface OutgoingItem {
MessageId getId(); MessageId getId();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment