/** * This class is responsible for reloading the list of local messages for a given folder, * notifying the adapter that the message have been loaded and queueing up a remote update of the * folder. */ private void checkMail(FolderInfoHolder folder) { TracingPowerManager pm = TracingPowerManager.getPowerManager(this); final TracingWakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "FolderList checkMail"); wakeLock.setReferenceCounted(false); wakeLock.acquire(K9.WAKE_LOCK_TIMEOUT); MessagingListener listener = new MessagingListener() { @Override public void synchronizeMailboxFinished( Account account, String folder, int totalMessagesInMailbox, int numNewMessages) { if (!account.equals(mAccount)) { return; } wakeLock.release(); } @Override public void synchronizeMailboxFailed(Account account, String folder, String message) { if (!account.equals(mAccount)) { return; } wakeLock.release(); } }; MessagingController.getInstance(getApplication()) .synchronizeMailbox(mAccount, folder.name, listener, null); sendMail(mAccount); }
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); FolderInfoHolder folder = (FolderInfoHolder) mAdapter.getItem(info.position); switch (item.getItemId()) { case R.id.open_folder: onOpenFolder(folder.name); break; case R.id.mark_all_as_read: onMarkAllAsRead(mAccount, folder.name); break; case R.id.send_messages: sendMail(mAccount); break; case R.id.check_mail: checkMail(folder); break; case R.id.folder_settings: onEditFolder(mAccount, folder.name); break; case R.id.empty_trash: onEmptyTrash(mAccount); break; case R.id.expunge: onExpunge(mAccount, folder.name); break; case R.id.clear_local_folder: onClearFolder(mAccount, folder.name); break; } return super.onContextItemSelected(item); }