Esempio n. 1
0
 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();
     }
   }
 }
Esempio n. 2
0
          @Override
          public void setPushActive(Account account, String folderName, boolean enabled) {
            if (!account.equals(mAccount)) {
              return;
            }
            FolderInfoHolder holder = getFolder(folderName);

            if (holder != null) {
              holder.pushActive = enabled;

              mHandler.dataChanged();
            }
          }
Esempio n. 3
0
          @Override
          public void synchronizeMailboxFailed(Account account, String folder, String message) {
            super.synchronizeMailboxFailed(account, folder, message);
            if (!account.equals(mAccount)) {
              return;
            }

            mHandler.progress(false);

            mHandler.folderLoading(folder, false);

            //   String mess = truncateStatus(message);

            //   mHandler.folderStatus(folder, mess);
            FolderInfoHolder holder = getFolder(folder);

            if (holder != null) {
              holder.lastChecked = 0;
            }

            mHandler.dataChanged();
          }
Esempio n. 4
0
          @Override
          public void listFolders(Account account, Folder[] folders) {
            if (account.equals(mAccount)) {

              List<FolderInfoHolder> newFolders = new LinkedList<FolderInfoHolder>();
              List<FolderInfoHolder> topFolders = new LinkedList<FolderInfoHolder>();

              Account.FolderMode aMode = account.getFolderDisplayMode();
              Preferences prefs =
                  Preferences.getPreferences(getApplication().getApplicationContext());
              for (Folder folder : folders) {
                try {
                  folder.refresh(prefs);

                  Folder.FolderClass fMode = folder.getDisplayClass();

                  if ((aMode == Account.FolderMode.FIRST_CLASS
                          && fMode != Folder.FolderClass.FIRST_CLASS)
                      || (aMode == Account.FolderMode.FIRST_AND_SECOND_CLASS
                          && fMode != Folder.FolderClass.FIRST_CLASS
                          && fMode != Folder.FolderClass.SECOND_CLASS)
                      || (aMode == Account.FolderMode.NOT_SECOND_CLASS
                          && fMode == Folder.FolderClass.SECOND_CLASS)) {
                    continue;
                  }
                } catch (MessagingException me) {
                  Log.e(
                      K9.LOG_TAG,
                      "Couldn't get prefs to check for displayability of folder "
                          + folder.getName(),
                      me);
                }

                FolderInfoHolder holder = null;

                int folderIndex = getFolderIndex(folder.getName());
                if (folderIndex >= 0) {
                  holder = (FolderInfoHolder) getItem(folderIndex);
                }
                int unreadMessageCount = 0;
                try {
                  unreadMessageCount = folder.getUnreadMessageCount();
                } catch (Exception e) {
                  Log.e(
                      K9.LOG_TAG,
                      "Unable to get unreadMessageCount for "
                          + mAccount.getDescription()
                          + ":"
                          + folder.getName());
                }

                if (holder == null) {
                  holder = new FolderInfoHolder(context, folder, mAccount, unreadMessageCount);
                } else {
                  holder.populate(context, folder, mAccount, unreadMessageCount);
                }
                if (folder.isInTopGroup()) {
                  topFolders.add(holder);
                } else {
                  newFolders.add(holder);
                }
              }
              Collections.sort(newFolders);
              Collections.sort(topFolders);
              topFolders.addAll(newFolders);
              mHandler.newFolders(topFolders);
            }
            super.listFolders(account, folders);
          }
Esempio n. 5
0
 public int getFolderIndex(String folder) {
   FolderInfoHolder searchHolder = new FolderInfoHolder();
   searchHolder.name = folder;
   return mFolders.indexOf(searchHolder);
 }