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(); } } }
/** * Returns an array of the accounts on the system. If no accounts are registered the method * returns an empty array. * * @return all accounts with {@link Account#isAvailable(Context)} */ public synchronized Collection<Account> getAvailableAccounts() { Account[] allAccounts = getAccounts(); Collection<Account> retval = new ArrayList<Account>(accounts.size()); for (Account account : allAccounts) { if (account.isEnabled() && account.isAvailable(mContext)) { retval.add(account); } } return retval; }
/** * Returns an array of the accounts on the system. If no accounts are registered the method * returns an empty array. * * @return all accounts with {@link Account#isAvailable(Context)} */ public synchronized Collection<Account> getAvailableAccounts() { if (accounts == null) { loadAccounts(); } if ((newAccount != null) && newAccount.getAccountNumber() != -1) { accounts.add(newAccount); newAccount = null; } Collection<Account> retval = new ArrayList<Account>(accounts.size()); for (Account account : accounts) { if (account.isAvailable(mContext)) { retval.add(account); } } return retval; }
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(); } } }
/** * On resume we refresh the folder list (in the background) and we refresh the messages for any * folder that is currently open. This guarantees that things like unread message count and read * status are updated. */ @Override public void onResume() { super.onResume(); if (!mAccount.isAvailable(this)) { Log.i(K9.LOG_TAG, "account unavaliabale, not showing folder-list but account-list"); startActivity(new Intent(this, Accounts.class)); finish(); return; } if (mAdapter == null) initializeActivityView(); MessagingController.getInstance(getApplication()).addListener(mAdapter.mListener); // mAccount.refresh(Preferences.getPreferences(this)); MessagingController.getInstance(getApplication()) .getAccountStats(this, mAccount, mAdapter.mListener); onRefresh(!REFRESH_REMOTE); MessagingController.getInstance(getApplication()).notifyAccountCancel(this, mAccount); }