mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-27 03:12:18 -05:00
ConversationActivity: Cache field lookups and add buffer via bulk method
This commit is contained in:
parent
c63c332158
commit
6996b4acee
@ -20,6 +20,8 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
package org.yaaic.view;
|
package org.yaaic.view;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -105,7 +107,10 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
|
|
||||||
switcher = (ViewSwitcher) findViewById(R.id.switcher);
|
switcher = (ViewSwitcher) findViewById(R.id.switcher);
|
||||||
|
|
||||||
for (Conversation conversation : server.getConversations()) {
|
// Optimization : cache field lookups
|
||||||
|
Collection<Conversation> mConversations = server.getConversations();
|
||||||
|
|
||||||
|
for (Conversation conversation : mConversations) {
|
||||||
onNewConversation(conversation.getName());
|
onNewConversation(conversation.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,8 +125,7 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
|
|
||||||
((ImageView) findViewById(R.id.status)).setImageResource(server.getStatusIcon());
|
((ImageView) findViewById(R.id.status)).setImageResource(server.getStatusIcon());
|
||||||
|
|
||||||
Intent intent = new Intent(this, IRCService.class);
|
bindService(new Intent(this, IRCService.class), this, 0);
|
||||||
bindService(intent, this, 0);
|
|
||||||
|
|
||||||
channelReceiver = new ConversationReceiver(server.getId(), this);
|
channelReceiver = new ConversationReceiver(server.getId(), this);
|
||||||
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_MESSAGE));
|
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_MESSAGE));
|
||||||
@ -137,12 +141,16 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
((EditText) findViewById(R.id.input)).setEnabled(true);
|
((EditText) findViewById(R.id.input)).setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optimization - cache field lookup
|
||||||
|
Collection<Conversation> mConversations = server.getConversations();
|
||||||
|
MessageListAdapter mAdapter;
|
||||||
|
|
||||||
// Fill view with messages that have been buffered while paused
|
// Fill view with messages that have been buffered while paused
|
||||||
for (Conversation conversation : server.getConversations()) {
|
for (Conversation conversation : mConversations) {
|
||||||
while (conversation.hasBufferedMessages()) {
|
mAdapter = conversation.getMessageListAdapter();
|
||||||
if (conversation.getMessageListAdapter() != null) {
|
|
||||||
conversation.getMessageListAdapter().addMessage(conversation.pollBufferedMessage());
|
if (mAdapter != null) {
|
||||||
}
|
mAdapter.addBulkMessages(conversation.getBuffer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user