mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-12-01 13:22:20 -05:00
Clear message buffer if view has been build from history
This commit is contained in:
parent
ecfa10f483
commit
59b590a2ee
@ -54,6 +54,8 @@ public class MessageListAdapter extends BaseAdapter
|
|||||||
for (Message message : channel.getHistory()) {
|
for (Message message : channel.getHistory()) {
|
||||||
messages.add(message.renderTextView(context));
|
messages.add(message.renderTextView(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
channel.clearBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,8 +91,24 @@ public class Channel
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Message pollMessage()
|
public Message pollBufferedMessage()
|
||||||
{
|
{
|
||||||
return buffer.poll();
|
return buffer.poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the channel have buffered messages?
|
||||||
|
*/
|
||||||
|
public boolean hasBufferedMessages()
|
||||||
|
{
|
||||||
|
return buffer.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the message buffer
|
||||||
|
*/
|
||||||
|
public void clearBuffer()
|
||||||
|
{
|
||||||
|
buffer.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,18 +218,21 @@ public class ServerActivity extends Activity implements ServiceConnection, Chann
|
|||||||
public void onChannelMessage(String target)
|
public void onChannelMessage(String target)
|
||||||
{
|
{
|
||||||
Log.d(TAG, "Message for target " + target);
|
Log.d(TAG, "Message for target " + target);
|
||||||
|
Channel channel = server.getChannel(target);
|
||||||
|
|
||||||
Message message = server.getChannel(target).pollMessage();
|
while(channel.hasBufferedMessages()) {
|
||||||
MessageListView view = (MessageListView) deckAdapter.getItemByName(target);
|
Message message = channel.pollBufferedMessage();
|
||||||
|
MessageListView view = (MessageListView) deckAdapter.getItemByName(target);
|
||||||
|
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
MessageListAdapter adapter = view.getAdapter();
|
MessageListAdapter adapter = view.getAdapter();
|
||||||
adapter.addMessage(message);
|
adapter.addMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deckAdapter.isSwitched()) {
|
if (deckAdapter.isSwitched()) {
|
||||||
MessageListView switchedView = deckAdapter.getSwitchedView();
|
MessageListView switchedView = deckAdapter.getSwitchedView();
|
||||||
switchedView.getAdapter().addMessage(message);
|
switchedView.getAdapter().addMessage(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user