/** * Finds the main conversation in a wave. The main conversation is defined as * the root if there is one, or the first unanchored conversation otherwise. */ public static Conversation getMainConversation(ConversationView view) { Conversation root = view.getRoot(); if (root == null) { for (Conversation curr : view.getConversations()) { if (!curr.hasAnchor()) { root = curr; break; } } } return root; } }
void populate(ConversationBlip blip, FakeBlipView blipUi) { for (ThreadBuilder threadBuilder : unanchored) { ConversationThread thread = blip.addReplyThread(); threadBuilder.populate(thread, blipUi.insertDefaultAnchorBefore(null, thread).getThread()); } for (ThreadBuilder threadBuilder : anchored) { ConversationThread thread = blip.addReplyThread(blip.getContent().size() - 1); FakeAnchor anchor = blipUi.insertDefaultAnchorBefore(null, thread); FakeInlineThreadView threadUi = anchor.getThread(); threadBuilder.populate(thread, threadUi); anchor.detach(threadUi); blipUi.getMeta().createInlineAnchorBefore(null, thread).attach(threadUi); } for (ConversationBuilder conversationBuilder : privates) { Conversation conversation = wave.createConversation(); conversation.setAnchor(blip.getConversation().createAnchor(blip)); assert conversation.hasAnchor(); conversationBuilder.populate( conversation, blipUi.insertConversationBefore(null, conversation)); } }
void populate(ConversationBlip blip, FakeBlipView blipUi) { for (ThreadBuilder threadBuilder : unanchored) { ConversationThread thread = blip.addReplyThread(); threadBuilder.populate(thread, blipUi.insertDefaultAnchorBefore(null, thread).getThread()); } for (ThreadBuilder threadBuilder : anchored) { ConversationThread thread = blip.addReplyThread(blip.getContent().size() - 1); FakeAnchor anchor = blipUi.insertDefaultAnchorBefore(null, thread); FakeInlineThreadView threadUi = anchor.getThread(); threadBuilder.populate(thread, threadUi); anchor.detach(threadUi); blipUi.getMeta().createInlineAnchorBefore(null, thread).attach(threadUi); } for (ConversationBuilder conversationBuilder : privates) { Conversation conversation = wave.createConversation(); conversation.setAnchor(blip.getConversation().createAnchor(blip)); assert conversation.hasAnchor(); conversationBuilder.populate( conversation, blipUi.insertConversationBefore(null, conversation)); } }