Changeset 702 for trunk/LogicMail/src/org/logicprobe
- Timestamp:
- 09/06/10 14:45:51 (17 months ago)
- Location:
- trunk/LogicMail/src/org/logicprobe/LogicMail
- Files:
-
- 10 edited
-
mail/AbstractIncomingMailClient.java (modified) (1 diff)
-
mail/IncomingMailClient.java (modified) (1 diff)
-
mail/IncomingMailConnectionHandler.java (modified) (6 diffs)
-
mail/imap/ImapClient.java (modified) (1 diff)
-
mail/pop/PopClient.java (modified) (1 diff)
-
model/MailboxNode.java (modified) (3 diffs)
-
ui/AbstractScreenProvider.java (modified) (4 diffs)
-
ui/CompositionScreen.java (modified) (2 diffs)
-
ui/MailHomeScreen.java (modified) (2 diffs)
-
ui/MailboxScreen.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LogicMail/src/org/logicprobe/LogicMail/mail/AbstractIncomingMailClient.java
r656 r702 141 141 return false; 142 142 } 143 144 public int getFolderMessageUpdateFrequency() {145 return 10;146 }147 143 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/mail/IncomingMailClient.java
r656 r702 301 301 302 302 /** 303 * Gets the frequency with which folder message updates should be passed304 * to higher levels of the application. This value should be a best guess305 * based on how long it takes to receive and parse incoming folder message306 * data.307 *308 * @return Recommended folder message update frequency309 */310 int getFolderMessageUpdateFrequency();311 312 /**313 303 * Get a particular message from the selected folder. 314 304 * <p> -
trunk/LogicMail/src/org/logicprobe/LogicMail/mail/IncomingMailConnectionHandler.java
r656 r702 303 303 304 304 private static class GetFolderMessageCallback implements FolderMessageCallback { 305 private int maxCount;306 305 private int type; 307 306 private FolderTreeItem folder; … … 309 308 private Object tag; 310 309 private Object param; 311 private FolderMessage[] folderMessages; 312 private int count; 313 314 public GetFolderMessageCallback(int maxCount, int type, FolderTreeItem folder, MailConnectionHandlerListener listener, Object tag) { 315 this(maxCount, type, folder, listener, null, tag); 316 } 317 318 public GetFolderMessageCallback(int maxCount, int type, FolderTreeItem folder, MailConnectionHandlerListener listener, Object param, Object tag) { 319 this.maxCount = maxCount; 310 311 public GetFolderMessageCallback(int type, FolderTreeItem folder, MailConnectionHandlerListener listener, Object tag) { 312 this(type, folder, listener, null, tag); 313 } 314 315 public GetFolderMessageCallback(int type, FolderTreeItem folder, MailConnectionHandlerListener listener, Object param, Object tag) { 320 316 this.type = type; 321 317 this.folder = folder; … … 323 319 this.param = param; 324 320 this.tag = tag; 325 this.count = 0;326 321 } 327 322 328 323 public void folderMessageUpdate(FolderMessage folderMessage) { 329 FolderMessage[] resultMessages = null; 330 synchronized(this) { 324 if(listener != null) { 331 325 if(folderMessage != null) { 332 if(count == 0) {333 folderMessages = new FolderMessage[maxCount];334 }335 folderMessages[count++] = folderMessage;336 }337 338 if(count == maxCount) {339 resultMessages = folderMessages;340 folderMessages = null;341 count = 0;342 }343 else if(folderMessage == null) {344 resultMessages = new FolderMessage[count];345 for(int i=0; i<count; i++) {346 resultMessages[i] = folderMessages[i];347 }348 folderMessages = null;349 count = 0;350 }351 }352 353 if(listener != null) {354 if(resultMessages != null) {355 326 if(param == null) { 356 listener.mailConnectionRequestComplete(type, new Object[] { folder, resultMessages}, tag);327 listener.mailConnectionRequestComplete(type, new Object[] { folder, new FolderMessage[] { folderMessage } }, tag); 357 328 } 358 329 else { 359 listener.mailConnectionRequestComplete(type, new Object[] { folder, resultMessages, param }, tag); 360 } 361 } 362 363 // If this is the last update of the sequence, make sure we notify 364 // the listener with a null array so it knows we are done. 365 if(folderMessage == null) { 330 listener.mailConnectionRequestComplete(type, new Object[] { folder, new FolderMessage[] { folderMessage }, param }, tag); 331 } 332 } 333 else { 334 // If this is the last update of the sequence, make sure we 335 // notify the listener with a null array so it knows we are done. 366 336 if(param == null) { 367 337 listener.mailConnectionRequestComplete(type, new Object[] { folder, null }, tag); … … 383 353 firstIndex, lastIndex, 384 354 new GetFolderMessageCallback( 385 incomingClient.getFolderMessageUpdateFrequency(),386 355 REQUEST_FOLDER_MESSAGES_RANGE, 387 356 folder, … … 398 367 messageTokens, 399 368 new GetFolderMessageCallback( 400 incomingClient.getFolderMessageUpdateFrequency(),401 369 REQUEST_FOLDER_MESSAGES_SET, 402 370 folder, … … 413 381 flagsOnly, 414 382 new GetFolderMessageCallback( 415 incomingClient.getFolderMessageUpdateFrequency(),416 383 REQUEST_FOLDER_MESSAGES_RECENT, 417 384 folder, -
trunk/LogicMail/src/org/logicprobe/LogicMail/mail/imap/ImapClient.java
r698 r702 853 853 854 854 /* (non-Javadoc) 855 * @see org.logicprobe.LogicMail.mail.IncomingMailClient#getFolderMessageUpdateFrequency()856 */857 public int getFolderMessageUpdateFrequency() {858 return 5;859 }860 861 /* (non-Javadoc)862 855 * @see org.logicprobe.LogicMail.mail.IncomingMailClient#getMessage(org.logicprobe.LogicMail.mail.MessageToken, org.logicprobe.LogicMail.mail.MailProgressHandler) 863 856 */ -
trunk/LogicMail/src/org/logicprobe/LogicMail/mail/pop/PopClient.java
r698 r702 396 396 397 397 /* (non-Javadoc) 398 * @see org.logicprobe.LogicMail.mail.IncomingMailClient#getFolderMessageUpdateFrequency()399 */400 public int getFolderMessageUpdateFrequency() {401 return 2;402 }403 404 /* (non-Javadoc)405 398 * @see org.logicprobe.LogicMail.mail.IncomingMailClient#getMessage(org.logicprobe.LogicMail.mail.MessageToken, org.logicprobe.LogicMail.mail.MailProgressHandler) 406 399 */ -
trunk/LogicMail/src/org/logicprobe/LogicMail/model/MailboxNode.java
r701 r702 1071 1071 1072 1072 private class RefreshMessagesThread extends Thread implements MessageNodeCallback { 1073 private Vector messagesToAdd = new Vector();1074 1075 1073 public RefreshMessagesThread() { 1076 1074 … … 1081 1079 try { 1082 1080 MailFileManager.getInstance().readMessageNodes(MailboxNode.this, this); 1083 addLoadedMessages();1084 1081 1085 1082 // If the server fetch completed before the cache load, then … … 1129 1126 } 1130 1127 } 1131 messagesToAdd.addElement(messageNode); 1132 if(messagesToAdd.size() == 4) { 1133 addLoadedMessages(); 1134 } 1135 } 1136 } 1137 1138 private void addLoadedMessages() { 1139 int size = messagesToAdd.size(); 1140 if(size == 0) { return; } 1141 1142 MessageNode[] messageArray = new MessageNode[size]; 1143 messagesToAdd.copyInto(messageArray); 1144 messagesToAdd.removeAllElements(); 1145 MailboxNode.this.addMessages(messageArray); 1128 MailboxNode.this.addMessage(messageNode); 1129 } 1146 1130 } 1147 1131 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/AbstractScreenProvider.java
r671 r702 31 31 package org.logicprobe.LogicMail.ui; 32 32 33 import java.util.Vector; 34 33 35 import net.rim.device.api.i18n.ResourceBundle; 34 36 … … 36 38 37 39 import net.rim.device.api.ui.Screen; 40 import net.rim.device.api.ui.UiApplication; 38 41 import net.rim.device.api.ui.component.Menu; 39 42 … … 47 50 protected Screen screen; 48 51 private StandardScreen standardScreen; 52 private final Object invokeLock = new Object(); 53 private Vector invokeItems = new Vector(); 54 private boolean invokeInProgress = false; 49 55 50 56 /* (non-Javadoc) … … 153 159 public void shortcutAction(ShortcutItem item) { 154 160 } 161 162 /** 163 * Puts the runnable object within this screen's UI event queue, so that it 164 * is run on the application's UI event queue. This intermediate queue is 165 * necessary to prevent the event thread from filling up with items in 166 * cases where the screen experiences a lot of updates. 167 * 168 * @param runnable the runnable object 169 */ 170 public void invokeLater(Runnable runnable) { 171 synchronized(invokeLock) { 172 invokeItems.addElement(runnable); 173 if(!invokeInProgress) { 174 invokeInProgress = true; 175 UiApplication.getUiApplication().invokeLater(invokeLaterRunnable); 176 } 177 } 178 } 179 180 private final Runnable invokeLaterRunnable = new Runnable() { 181 public void run() { 182 Vector currentInvokeItems; 183 synchronized(invokeLock) { 184 currentInvokeItems = invokeItems; 185 invokeItems = new Vector(); 186 } 187 int size = currentInvokeItems.size(); 188 for(int i=0; i<size; i++) { 189 Runnable runnable = (Runnable)currentInvokeItems.elementAt(i); 190 runnable.run(); 191 } 192 synchronized(invokeLock) { 193 invokeInProgress = false; 194 } 195 } 196 }; 155 197 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/CompositionScreen.java
r701 r702 48 48 import net.rim.device.api.ui.MenuItem; 49 49 import net.rim.device.api.ui.Screen; 50 import net.rim.device.api.ui.UiApplication;51 50 import net.rim.device.api.ui.component.AutoTextEditField; 52 51 import net.rim.device.api.ui.component.Dialog; … … 223 222 224 223 // Schedule the UI update 225 UiApplication.getUiApplication().invokeLater(new EventObjectRunnable(e) {224 invokeLater(new EventObjectRunnable(e) { 226 225 public void run() { 227 226 MessageNode messageNode = (MessageNode)getEvent().getSource(); -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/MailHomeScreen.java
r701 r702 408 408 } 409 409 410 public void populateMailTree(MailHomeTreeNode rootNode) { 411 synchronized(UiApplication.getEventLock()) { 412 // Clear any existing nodes 413 treeField.deleteAll(); 414 nodeIdMap.clear(); 415 416 // Freshly populate the tree 417 int firstNode = -1; 418 MailHomeTreeNode[] nodes = rootNode.children; 419 if(nodes != null) { 420 for(int i = nodes.length - 1; i >= 0; --i) { 421 int id = treeField.addChildNode(0, nodes[i]); 422 nodeIdMap.put(nodes[i], id); 423 if(i == 0) { firstNode = id; } 424 populateMailTreeChildren(id, nodes[i]); 425 } 426 } 427 if(firstNode != -1) { 428 treeField.setCurrentNode(firstNode); 429 } 430 } 410 public void populateMailTree(final MailHomeTreeNode rootNode) { 411 UiApplication.getUiApplication().invokeAndWait(new Runnable() { 412 public void run() { 413 // Clear any existing nodes 414 treeField.deleteAll(); 415 nodeIdMap.clear(); 416 417 // Freshly populate the tree 418 int firstNode = -1; 419 MailHomeTreeNode[] nodes = rootNode.children; 420 if(nodes != null) { 421 for(int i = nodes.length - 1; i >= 0; --i) { 422 int id = treeField.addChildNode(0, nodes[i]); 423 nodeIdMap.put(nodes[i], id); 424 if(i == 0) { firstNode = id; } 425 populateMailTreeChildren(id, nodes[i]); 426 } 427 } 428 if(firstNode != -1) { 429 treeField.setCurrentNode(firstNode); 430 } 431 } 432 }); 431 433 } 432 434 … … 444 446 final int nodeId = nodeIdMap.get(node); 445 447 if(nodeId != -1) { 446 UiApplication.getUiApplication().invokeLater(new Runnable() {448 invokeLater(new Runnable() { 447 449 public void run() { 448 450 treeField.invalidateNode(nodeId); -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/MailboxScreen.java
r701 r702 47 47 import net.rim.device.api.ui.component.Menu; 48 48 import net.rim.device.api.ui.container.VerticalFieldManager; 49 import net.rim.device.api.ui.UiApplication;50 49 import net.rim.device.api.util.Comparator; 51 50 import net.rim.device.api.util.DateTimeUtilities; … … 121 120 if((e.getGlobalChange() & GlobalConfig.CHANGE_TYPE_OTHER) != 0) { 122 121 if(globalConfig.getDispOrder() != displayOrder) { 123 UiApplication.getUiApplication().invokeLater(new EventObjectRunnable(e) {122 invokeLater(new EventObjectRunnable(e) { 124 123 public void run() { 125 124 displayOrder = !displayOrder; … … 129 128 } 130 129 if(globalConfig.getHideDeletedMsg() != hideDeleted) { 131 UiApplication.getUiApplication().invokeLater(new EventObjectRunnable(e) {130 invokeLater(new EventObjectRunnable(e) { 132 131 public void run() { 133 132 hideDeleted = !hideDeleted; … … 143 142 private MailboxNodeListener mailboxNodeListener = new MailboxNodeListener() { 144 143 public void mailboxStatusChanged(MailboxNodeEvent e) { 145 UiApplication.getUiApplication().invokeLater(new EventObjectRunnable(e) {144 invokeLater(new EventObjectRunnable(e) { 146 145 public void run() { 147 146 mailboxNode_MailboxStatusChanged((MailboxNodeEvent)getEvent()); … … 154 153 private MessageNodeListener messageNodeListener = new MessageNodeListener() { 155 154 public void messageStatusChanged(MessageNodeEvent e) { 156 UiApplication.getUiApplication().invokeLater(new EventObjectRunnable(e) {155 invokeLater(new EventObjectRunnable(e) { 157 156 public void run() { 158 157 messageNode_MessageStatusChanged((MessageNodeEvent)getEvent());
Note: See TracChangeset
for help on using the changeset viewer.
