private void refreshFolder(Account account, String folderName) { // There has to be a cheaper way to get at the localFolder object than this Folder localFolder = null; try { if (account != null && folderName != null) { if (!account.isAvailable(FolderList.this)) { Log.i(K9.LOG_TAG, "not refreshing folder of unavailable account"); return; } localFolder = account.getLocalStore().getFolder(folderName); int unreadMessageCount = localFolder.getUnreadMessageCount(); FolderInfoHolder folderHolder = getFolder(folderName); if (folderHolder != null) { folderHolder.populate(context, localFolder, mAccount, unreadMessageCount); mHandler.dataChanged(); } } } catch (Exception e) { Log.e(K9.LOG_TAG, "Exception while populating folder", e); } finally { if (localFolder != null) { localFolder.close(); } } }
private void onClearFolder(Account account, String folderName) { // There has to be a cheaper way to get at the localFolder object than this LocalFolder localFolder = null; try { if (account == null || folderName == null || !account.isAvailable(FolderList.this)) { Log.i(K9.LOG_TAG, "not clear folder of unavailable account"); return; } localFolder = account.getLocalStore().getFolder(folderName); localFolder.open(Folder.OpenMode.READ_WRITE); localFolder.clearAllMessages(); } catch (Exception e) { Log.e(K9.LOG_TAG, "Exception while clearing folder", e); } finally { if (localFolder != null) { localFolder.close(); } } }