From 0c27a1ab0e8672d41c3429211f737850c6274c96 Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 3 Sep 2010 00:56:19 +0000 Subject: [PATCH] Avoid division by zero. Fixes issue 2259 --- src/com/fsck/k9/activity/MessageList.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 262110a77..b5a077e89 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -308,10 +308,14 @@ public class MessageList if (mCurrentFolder != null && mCurrentFolder.loading && mAdapter.mListener.getFolderTotal() > 0) { - level = (Window.PROGRESS_END / mAdapter.mListener.getFolderTotal()) * (mAdapter.mListener.getFolderCompleted()) ; - if (level > Window.PROGRESS_END) + int divisor = mAdapter.mListener.getFolderTotal(); + if (divisor != 0) { - level = Window.PROGRESS_END; + level = (Window.PROGRESS_END / divisor) * (mAdapter.mListener.getFolderCompleted()) ; + if (level > Window.PROGRESS_END) + { + level = Window.PROGRESS_END; + } } } @@ -2061,7 +2065,7 @@ public class MessageList private void addOrUpdateMessages(final Account account, final String folder, final List providedMessages, final boolean verifyAgainstSearch) { // we copy the message list because the callback doesn't expect - // the callbacks to mutate it. + // the callbacks to mutate it. final List messages = new ArrayList(providedMessages); runOnUiThread(new Runnable()